(adsbygoogle = window.adsbygoogle || []).push({});
Hi all,
Today I'm releasing a math expression parser I built a while ago.
Here's a guide on parsing expressions:
If you want to parse an infix expression (normal expression), use the following code:
[/FONT]
[FONT=Open Sans]MathulatorParser.Parser parser = new MathulatorParser.Parser();[/FONT]
[FONT=Open Sans]decimal e = parser.ParseExpression("2 + 2 / 4 * -1 + 6 / cos(4 - 2 + 3)");[/FONT]
[FONT=Open Sans]
As you can see, this parser is able to parse math functions such as cos(), sin(), and tan().
If you want to parse an postfix expression (Reverse Polish Notation), use the following code:
[/FONT]
[FONT=Open Sans]MathulatorParser.Parser parser = new MathulatorParser.Parser();[/FONT]
[FONT=Open Sans]decimal p = parser.EvaluatePostfix("2 2 + 3 / -");[/FONT]
[FONT=Open Sans]
If you want to show the built in calculator, use the following code:
[/FONT]
[FONT=Open Sans]MathulatorParser.MathulatorProgram program = new MathulatorParser.MathulatorProgram();[/FONT]
[FONT=Open Sans]program.Show();[/FONT]
[FONT=Open Sans]
Here's the download to the Mathulator library:
You must login or register to view this content.
Here is the download link to the source code:
You must login or register to view this content.
If you use this in your program, please leave me credits.
I hope you enjoy the program
Thanks,
Ro