nicolewhite / algebra.js

Build, display, and solve algebraic equations.
http://algebra.js.org
MIT License
1.34k stars 111 forks source link

Double sign gets errors in algebra.parse() #88

Open sjorsvanheuveln opened 6 years ago

sjorsvanheuveln commented 6 years ago

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');

timleland commented 6 years ago

Any workaround for this issue?

timrach commented 6 years ago

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)');

sjorsvanheuveln commented 6 years ago

0.2.6

timleland commented 6 years ago

@timrach I wrapped them in brackets. Thanks