# Floating Point Arithmetic and The Descent into Madness

[This article was first published on

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

**John Myles White » Statistics**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

While I should confess upfront that I’ve always had a weaker command of the details of floating point arithmetic than I feel I ought to have, this sort of thing still blows my mind when I stumble upon it. These moments invariably make me realize that floating point math will simply never satisfy my naive hopes as a mathematician:

1 2 3 | 0.1 + 0.1 == 0.2 # True 0.1 + 0.1 + 0.1 == 0.3 # False 0.1 + 0.1 + 0.1 + 0.1 == 0.4 # True |

On my Intel Core 2 Duo machine running OS X, those statements have the indicated truth values in all three of Julia, R and Python.

Consider this evidence for the truth of the combined propositions, “God created the integers. All else is the work of man,” and “Out of the crooked timber of humanity no straight thing was ever made.”

To

**leave a comment**for the author, please follow the link and comment on their blog:**John Myles White » Statistics**.R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.