3 ms·
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 g
by jrockway 15y ago
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.
- mjb 15y ago> 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.
- jrockway 15y agoWhat 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.