views:

43

answers:

1

Is there a good math parser in Javascript? I want to be able to parse something like:

LOG(3.14)+5^2+POW(2,LN(X*2,Y))

Thanks,

+1  A: 

Use this one. It defined an "operator" object that lets you define your own operators.

http://jsfromhell.com/classes/math-processor

Warning: it uses with. If you don't know why that's dangerous, find out before using this code in anything critical. Alternately, you could just re-write it without with.

Sir Robert
I wouldn't worry too much about `with` because of this: `{p: MathProcessor.prototype}`.
ChaosPandion