Hello, I have a question about basic addition in javaScript. When adding numbers with decimals together, the answer sometimes comes out different from what I expect. I’m not sure what’s going on. If anyone can help me understand, that would be appreciated.
Examples:
3.97 + 5.4 \returns 9.370000000000001
I expected 9.37
or
2.97 + 7.48 \returns 10.450000000000001
or
3.97 + 5.47 + 3.62 \returns 13.059999999999999
How do I make sure I get what I’m expecting rather than getting these slightly off returns?
Thanks.