jiggzson / nerdamer

a symbolic math expression evaluator for javascript
http://www.nerdamer.com
MIT License
514 stars 82 forks source link

Possible bug in subtract function? #606

Closed szoshi closed 3 years ago

szoshi commented 3 years ago

Hi, I have come across something which I cannot explain. Here is minimal code to reproduce it: var a = nerdamer('2x-y'); var b = nerdamer('2x-y+4'); b.subtract(a).toTex() gives 4 but a.subtract(b).toTex() returns 0 and not -4. Is there another way to get the difference between two terms? I am working with the dev branch btw. Thanks!

szoshi commented 3 years ago

Just verified that the demo on the webpage does the same. (2x-y) - (2x-y+4) gives 0.

jiggzson commented 3 years ago

@szoshi, fixed on dev. Thanks for bringing it to my attention.

szoshi commented 3 years ago

Tested. Works. Closing. Thanks!