Number of decimals in result

Topics: Help
Feb 4, 2014 at 7:51 AM
We are using NCalc to do some math. Expressions are dynamicly generated with values retrieved from our database (and i must say it works like a charm).

Our expression could look like this:


The result is obviously 19.4

The thing is, the number of decimals in our input values are important, and the result should confofm to this number. Since 4.45 and 5.25 have two decimals, the result should also have two decimals, and must be 19.40.

I know i can maniupulate this with ToString(), but it is hard for me to determine all the input, since it is one big string, and it could also be a boolean or string.

Is there any simple way to accomplish this using NCalc?