MikeMcl / bignumber.js

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

Calculation Expression Execution #297

Closed balamurugansd closed 2 years ago

balamurugansd commented 3 years ago

@MikeMcl Is it possible to execute the expression based on rules,

EG: a*b+c/d

For the above expression which is dynamic all the time, is it possible to evaluate accordingly, if so how? Will it take care of BODMAS rule?

MikeMcl commented 3 years ago
a = new BigNumber(1);
b = new BigNumber(2);
c = new BigNumber(3);
d = new BigNumber(4);

result = a.times(b).plus(c.div(d));

console.log(result.toString());    // '2.75'

Will it take care of BODMAS rule?

Please define acronyms the first time you use them.