simplealgebra
v0.0.6
Published
Perform the operations inside a parenthesis first, Then exponents, Then multiplication and division, from left to right, Then addition and subtraction, from left to right.
Downloads
2
Readme
SimpleAlgebra
Input:
const SimpleAlgebra = require('simplealgebra');
let expString = '(-2 + (- 0.9 - 0.1 + 3 * 3)) * (3 - 1)';
let test = new SimpleAlgebra(expString);
console.log(JSON.stringify(test, null, 4));
Output:
{
"steps": [
"(-2+(-0.9-0.1+3*3))*(3-1)",
"(-2+(-0.9-0.1+9))*(3-1)",
"(-2+(-1+9))*(3-1)",
"(-2+8)*(3-1)",
"6*(3-1)",
"6*2"
],
"operations": [
[
3,
"*",
3
],
[
-0.9,
"-",
0.1
],
[
-1,
"+",
9
],
[
-2,
"+",
8
],
[
3,
"-",
1
],
[
6,
"*",
2
]
]
}