Hacker News new | past | comments | ask | show | jobs | submit login

But never with floating point. I think that's the context of the whole article, and should really be the main take-home (which I'm not sure the article gets across clearly enough).



you can use it with floats just fine if your condition boundary is a "whole number float", like running from 0.0 to 1.0 in steps of "some small increment". It's only when your boundary has a non-zero fraction that you're going to have to be more careful.


>running from 0.0 to 1.0 in steps of "some small increment".

I'm not sure what you mean; those aren't integers (if that's what you mean by "whole number float"):

python3

>>> 0.4 == 0.6 - 0.2

False

(edit: formatting for python)


fair, that was completely the wrong example.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: