logoalt Hacker News

jmalickitoday at 10:27 AM2 repliesview on HN

.125 + .375 == .5

You should be using == for floats when they're actually equal. 0.1 just isn't an actual number.


Replies

emil-lptoday at 1:09 PM

Are you saying that my students should memorize which numbers are actual floats and which are not?

    > 1.25 * 0.1
    
    0.1250000000000000069388939039
show 5 replies
Sharlintoday at 10:40 AM

> 0.1 just isn't an actual number.

A finitist computer scientists only accepts those numbers as real that can be expressed exactly in finite base-two floating point?

show 3 replies