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

Incidentally, understanding how this works is helpful to programmers. If you know why this happens, you'll know why you can't write:

   double x = 0.1;
and get something that works.



> you can't write ... and get something that works.

That's taking things a bit far, isn't it? Sure, you can't exactly express 0.1 as a double - but you can get many things that work really well using the approximation.


What I meant to say was, "you can't expect something with a terminating representation in base 10 to always have a terminating representation in base 2". When you play with these cases in base 10, it builds intuition that can be applied to base 2 math.




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

Search: