algebra.js icon indicating copy to clipboard operation
algebra.js copied to clipboard

Double sign gets errors in algebra.parse()

Open sjorsvanheuveln opened this issue 6 years ago • 4 comments

This: algebrea.parse('12 -- 3');

Results in an error: SyntaxError: Missing operand

After trying some other stuff, it appears it just can't handle negative signs after the operator. E.g. this also fails: algebra.parse('-1 * -5');

sjorsvanheuveln avatar Feb 24 '18 23:02 sjorsvanheuveln

Any workaround for this issue?

timleland avatar Mar 06 '18 03:03 timleland

What version are you on? When I try this in the browser console at http://algebra.js.org/ it gets parsed and evaluated to "9" - which is not the correct evaluation but also not the Syntax Error you get.

Any workaround for this issue?

The workaround would be to wrap the negative number in brackets: algebra.parse('12 - (- 3)');

timrach avatar Mar 29 '18 16:03 timrach

0.2.6

sjorsvanheuveln avatar Mar 29 '18 16:03 sjorsvanheuveln

@timrach I wrapped them in brackets. Thanks

timleland avatar Mar 30 '18 23:03 timleland