evaluate math expressions

  • Thread starter Thread starter OJO
  • Start date Start date
O

OJO

Hello microsoft.public.dotnet.framework!

I'm wondering if there is any class in framework that provides ability
to evaluate math expressions like for example "(2+2*8)^2".

I searched through assemblies but found nothing usueful.

As my application uses internet connection, I though about using google
calculator, but I don't know if google can be used as webservice to get
the result.

I'll be very thankful for any help.

OJO
 
R.Balaji said:
Read more on Google web service...
http://www.google.com/apis/

I can't use it. The first reason is that I don't agree with the terms of
licence (it won't be personal use) and the another one is that when I
call google as webservice it doesn't use calculator but returns www
results instead.

OJO
 
There is no class that does this in the .net framework.
Depending on your requirements, I'd suggest 3 options:
- use someone else's or build your own calculator class. It's not that hard,
and almost any parser generator includes one as a sample (try e.g. ANTLR)
- Look for a way to include the JScript or VBScript hosts in .net. They can
be used as COM components, this shouldn't be too hard. Both provide a
solution for your problem, although they are much more powerful (containing
logical/bitwise operations, string operations...)
- You might also use dynamic code generation/compilation, but the produced
IL code will never get recycled. However this will definitely be the fastest
way, as it results in native code.

Niki
 
Back
Top