MathNet real double precision issue


#1

I need to write a function to compare the string value “15.0000000000000001” to “15” and I am using MathNet. Using MathNet.Symbolics.Expression.Real only accepts double. When I do the following

Expression valOne = Expression.Real(Double.Parse(“15.0000000000000001”));
Expression valTwo = Expression.Real(Double.Parse(“15”));

valOne.Equals(valTwo);
The above evaluates to true.Double.Parse 15.0000000000000001 returns 15. I understand the 0’s after the decimal is meaningless to double and it has storage limitations.

Could anybody please help?


#2

You can use BigRational. But you will need to translate the number in rational fraction.