-
Notifications
You must be signed in to change notification settings - Fork 37
Strange bug with #negative #42
Comments
OK… So, the AST is correct. Can you find a Minimal Working Example? |
I cannot reproduce. |
ping? |
Oh, finally I can reproduce! |
ExplanationsFor Hoa,
SolutionWorking on it. |
Should we fix it 🙄? cc @jubianchi @CircleCode |
A solution would be to traverse the whole expression, apply simplifications, and then evaluate it. Else, there will still be an edge case somewhere. |
I think we should do our best to fix this issue. It will clarify both usages and contributions. When I found this bug, I had a hard time figuring ou if I introduced this bug or if it was already here. In a user point of view, having the exact same behavior than PHP would make things totally predictable. |
Agree. I don't have time right now to fix it though :-(. |
Here is the expression I use :
$expr = '2 + 2 / 2560.4 + - 2';
With PHP, I get:
With Math, I get:
Here is the produced AST:
Changing the expression to:
2 + 2 / 2560.4 - 2
makes both results identical,2 + 2 / 2560.4 + - 3
makes both results identical,2 + 2 / 2560.3 + - 2
makes both results identical,2 + 2 / 2560.4 + - - 2
makes both results identical,2 + 2 / 2560.4 + - + 2
makes results different,Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: