lengstrom/MathEvaluator

Numbers don't add up to 0

Closed this issue · 1 comments

Try this: -5.2325873374938965+5.23258733749390
Result is: 3.5527, obviously it should be 0

Python returns:

-5.2325873374938965+5.23258733749390
3.552713678800501e-15

Line 131 in mathevaluator.py is flawed, it just truncates which is a bad idea. It should rather leave it alone or format the number using "%.4f" % float(evaluated).

Thanks, I'll fix this tonight.

On May 4, 2015, at 12:47 PM, rhuitl notifications@github.com wrote:

Try this: -5.2325873374938965+5.23258733749390
Result is: 3.5527, obviously it should be 0

Python returns:

-5.2325873374938965+5.23258733749390
3.552713678800501e-15

Line 131 in mathevaluator.py is flawed, it just truncates which is a bad idea. It should rather leave it alone or format the number using "%.4f" % float(evaluated).


Reply to this email directly or view it on GitHub.