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

I fully agree.

As a more general strategy, just use integers (preferably unsigned integers) for all critical stuff such as state handling and looping over. Then, perform floating point operations only on top of that, as a last step. Sometime you don't even need that and use fixed point arithmetics instead (i.e. change your unit to some fixed fraction, e.g. in accounting calculate with integer cents instead of floating point euros/dollars).




> Then, perform floating point operations only on top of that, as a last step.

Right. "Once you go float, you never go back."

Any time you need discrete operations like counting and equality, do it in integer space. Avoid going from integer space back to floating point space.




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

Search: