Sum of two values with two decimals resulted in wrong value


I am working a calculator issue where it resulted with wrong result. Observed that it is javascript which is causing this issue by returning wrong data to the calculator.

If we try to add "-47 -51.48" then it should result in "-98.48". But javascript resulted with value "-98.47999999999999". I have tested couple of use cases and it is working fine but only with some number it is having the issue. I know we have toFixed(x) method but i need all the correct decimal in the calculator.

Even I have tested outside my product like W3schools and MDN web docs. It resulted the same. You can refer to screenshot. Is it a bug or is there any way to fix it. I have the latest browser and tested in multiple browsers. Any help would be appreciated.

Let me know if it is not the right place to report an issue to get the solution.

No, this is not a bug, and not a problem specific to JavaScript. It is an inherent property of the floating point number representation. Learn about it at