Closed Roman-Kerimov closed 6 years ago
Ah... yes, because it's parsing the 2
, and then the ½
... it sees them as separate tokens, and assumes they're an implicit multiplication.
But I agree that's not ideal. :)
ok, I've got a rudimentary fix in place, but this has actually highlighted a deeper problem with DDMathParser's token resolution.
The current fix is to inject a +
operator in between a number and a fraction, however that will break evaluation for things like 2½ * 2
, because:
2 + ½ * 2
2 + (½ * 2)
2 + 1
3
I'm thinking I'll need to change how resolution is done in order to fully solve this.
I think that this problem can be solved by adding a special addition operator with the highest priority.
@Roman-Kerimov you're right, that's probably a simpler fix than what I was thinking. The fix has been pushed to master
. Thanks!
For example, "2½".evaluate() returns 1 instead of 2.5