MikeMcl / bignumber.js

A JavaScript library for arbitrary-precision decimal and non-decimal arithmetic
http://mikemcl.github.io/bignumber.js
MIT License
6.64k stars 741 forks source link

Built-in S-expression calculator #280

Closed septs closed 3 years ago

septs commented 3 years ago
// 1 + 2
BigNumber.calc('+', '1', '2')
// 1 + (2 * 3)
BigNumber.calc('+', '1', ['*', '2', '3'])
// 10 * (10 ** 100)
BigNumber.calc('*', '10', ['**', '10', '100'])
// 5 - (6 * 7)
BigNumber.calc('*', '-', '5', '6', '7')
// etc

by built-in polish notation calculator simplify code and logic.

see https://en.wikipedia.org/wiki/Polish_notation see https://en.wikipedia.org/wiki/S-expression

MikeMcl commented 3 years ago

Are you suggesting that I implement this?

I have extended my other library decimal.js with an expression evaluator.