Exponential operator
iserranoe opened this issue · 1 comments
iserranoe commented
The exponential operator used with Parser is ^; however, javascript exponential operator is **. Is there a way for Parser to accept ** as exponential operator?
//Standard JavaScript exponential
> 2**3
8
//eval function exponential
> eval('2**3')
8
//Not working with Parser
> Parser = require('expr-eval').Parser
[Function: Parser] { parse: [Function], evaluate: [Function] }
> Parser.evaluate('2**3')
Thrown:
Error: unexpected TOP: *
.....
//Working with other operator
> Parser.evaluate('2^3')
8
silentmatt commented
That's a good idea. I'm not a big fan of having multiple syntaxes for the same thing, but especially with JavaScript using **
, that would align with people's expectations. We could make it an option, but the extra complexity doesn't seem worth it, and it's easy enough to support both. There also shouldn't be any backward-compatibility issues, since **
is current a syntax error.