By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,700 Members | 1,512 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,700 IT Pros & Developers. It's quick & easy.

How to..

P: n/a
i have string "2+6/3-8/2" and how to get result (in this case is 0). String
can be any formula with 4 basic math operations
thx
Nov 21 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
You shouldn't approach the problem this way unless you want to write a LOT
of regular expression code! Instead the input should come in pieces. The
math operators should be determined by one input mechanism and the data
another, not all together. This is very poor design.

"Dzemo" <dz***@wizard.ba> wrote in message
news:ur**************@TK2MSFTNGP12.phx.gbl...
i have string "2+6/3-8/2" and how to get result (in this case is 0). String
can be any formula with 4 basic math operations
thx

Nov 21 '05 #2

P: n/a
You shouldn't approach the problem this way unless you want to write a LOT
of regular expression code! Instead the input should come in pieces. The
math operators should be determined by one input mechanism and the data
another, not all together. This is very poor design.

"Dzemo" <dz***@wizard.ba> wrote in message
news:ur**************@TK2MSFTNGP12.phx.gbl...
i have string "2+6/3-8/2" and how to get result (in this case is 0). String
can be any formula with 4 basic math operations
thx

Nov 21 '05 #3

P: n/a
Dzemo,

The only think I know about it is this link

http://www.eggheadcafe.com/articles/20030908.asp

I hope this helps?

Cor
i have string "2+6/3-8/2" and how to get result (in this case is 0). String
can be any formula with 4 basic math operations
thx

Nov 21 '05 #4

P: n/a
Dzemo,

The only think I know about it is this link

http://www.eggheadcafe.com/articles/20030908.asp

I hope this helps?

Cor
i have string "2+6/3-8/2" and how to get result (in this case is 0). String
can be any formula with 4 basic math operations
thx

Nov 21 '05 #5

P: n/a
Hi Dzemo

I'm tempted to say use JScript.NET!!

Try this:

1. Create a file called: DynamicMath.js
2. Add this code to it:

class DynamicMath
{
static function Eval(MathExpression : String) : double
{
return eval(MathExpression);

};
}

3. Compile it with the command line jsc compiler: jsc /t:library
DynamicMath.js
4. Add a reference to DynamicMath.dll to your project (and to
Microsoft.JScript.dll as well)
5. Use from your favourite .NET language:
Dim d As Double = DynamicMath.Eval("2 + 3 + 4")
MessageBox.Show(d)
6. That's it..

HTH

Nigel Armstrong
"Dzemo" wrote:
i have string "2+6/3-8/2" and how to get result (in this case is 0). String
can be any formula with 4 basic math operations
thx

Nov 21 '05 #6

P: n/a
Hi Dzemo

I'm tempted to say use JScript.NET!!

Try this:

1. Create a file called: DynamicMath.js
2. Add this code to it:

class DynamicMath
{
static function Eval(MathExpression : String) : double
{
return eval(MathExpression);

};
}

3. Compile it with the command line jsc compiler: jsc /t:library
DynamicMath.js
4. Add a reference to DynamicMath.dll to your project (and to
Microsoft.JScript.dll as well)
5. Use from your favourite .NET language:
Dim d As Double = DynamicMath.Eval("2 + 3 + 4")
MessageBox.Show(d)
6. That's it..

HTH

Nigel Armstrong
"Dzemo" wrote:
i have string "2+6/3-8/2" and how to get result (in this case is 0). String
can be any formula with 4 basic math operations
thx

Nov 21 '05 #7

P: n/a
"Dzemo" <dz***@wizard.ba> schrieb:
i have string "2+6/3-8/2" and how to get result (in this case is 0). String
can be any formula with 4 basic math operations


MathLib
<URL:http://palmbytes.de/content/dotnet/mathlib.htm>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #8

P: n/a
"Dzemo" <dz***@wizard.ba> schrieb:
i have string "2+6/3-8/2" and how to get result (in this case is 0). String
can be any formula with 4 basic math operations


MathLib
<URL:http://palmbytes.de/content/dotnet/mathlib.htm>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.