This question already has an answer here:
- Is floating point math broken? 31 answers
:
0.3-0.2-0.1 = -2.775558e-17 # in R3.4 / Python 3.5
While
0.4-0.2-0.1-0.1 = 0.
I am very confused now. I am aware of different storage types in both language. I came on this issue because, I needed to determine if a numeric variable (as a result of different arithmetic operations) is positive or negative.
I need to figure out a reliable way to check the sign of numeric variable.