Incorrect result on BigNumber subtraction #3069
Replies: 6 comments
-
Thanks for your question @brandoncollins7. I think that your expectation is that You're not the first to stumble upon this, see: #864. I will mark this as a duplicate, let's continue any discussion over there. |
Beta Was this translation helpful? Give feedback.
-
A good first step might be to throw an error when these functions are called with strings rather than silently converting to numbers. |
Beta Was this translation helpful? Give feedback.
-
I'm not sure about that, it is currently a feature that strings are converted into numbers. |
Beta Was this translation helpful? Give feedback.
-
Oh I see, so we want to keep converting strings to some numeric type. But allow what type that is to be configured? |
Beta Was this translation helpful? Give feedback.
-
It makes sense to have string input converted to a number type (number, BigNumber, Fraction) depending on the config option I don't think it will be trivial to implement such a change though. |
Beta Was this translation helpful? Give feedback.
-
I think this is a common question, so moving it to a Q&A discussion. |
Beta Was this translation helpful? Give feedback.
-
math.subtract("315051884410500000", "358209676795500000") = -4315779238500060
The correct answer should be: -43157792385000000. Why would this be happening? This can be replicated using the math.subtract method on the mathjs website via the chrome debugging console.
Beta Was this translation helpful? Give feedback.
All reactions