Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 205301

Strange arithmetic result [duplicate]

$
0
0

This question already has an answer here:

:

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.


Viewing all articles
Browse latest Browse all 205301

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>