pimath 0.0.29 → 0.0.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dev/index.html CHANGED
@@ -37,10 +37,15 @@
37
37
 
38
38
  <script>
39
39
  // let ne = new Pi.NumExp('5/x*sin(x*x)')
40
- let ne = new Pi.NumExp('5/x*sqrt(x^2)')
41
-
42
- console.log(ne.rpn)
43
- console.log(ne.evaluate({x: 0}))
40
+ const expr2 = new Pi.NumExp('-3*x^2-5')
41
+
42
+ console.log(expr2.evaluate({x: -2}))
43
+ //
44
+ //
45
+ // let ne = new Pi.NumExp('5/x*sqrt(x^2)')
46
+ //
47
+ // console.log(ne.rpn)
48
+ // console.log(ne.evaluate({x: 0}))
44
49
 
45
50
  function dev () {
46
51
  let output = []
package/dev/pi.js CHANGED
@@ -4334,7 +4334,7 @@ class NumExp {
4334
4334
  this._addToStack(stack, a + b);
4335
4335
  }
4336
4336
  else if (element.token === '-') {
4337
- const b = +stack.pop(), a = +stack.pop();
4337
+ const b = +stack.pop(), a = +stack.pop() || 0;
4338
4338
  this._addToStack(stack, a - b);
4339
4339
  }
4340
4340
  else if (element.token === '^') {