math-expressions icon indicating copy to clipboard operation
math-expressions copied to clipboard

Negative zero

Open tonypottera24 opened this issue 4 years ago • 1 comments

math_expressions: ^2.0.0

I'm wondering if this is a bug or an expected behavior?

Expression exp = Parser().parse("-1*0");
double eval = exp.evaluate(EvaluationType.REAL, null);
print(eval);
// -0.0

tonypottera24 avatar Mar 30 '20 02:03 tonypottera24

Thanks for the report. Looks like this is unintentional, as Dart itself evaluates -1*0.0 to positive zero, and only yields negative zero for 1*-0.0

fkleon avatar Mar 30 '20 03:03 fkleon