Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think floats should be treated like noisy analog values.

If you are doing something that requires you to reason about their precision beyond deciding how many bits is enough, you should probably not be using floats, because then you've added some more reasoning the next guy has to understand.

There is a good reason to compare float equality though: when there's no calculation involved and you're basically just comparing object identity.

Checking if a float timestamp has changed by comparing it to an old copy of exactly the same variable is fine.

They're like analog values that can be exactly stored and copied.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: