[Python-Dev] Feedback on new floating point info in tutorial

Greg Ewing greg@cosc.canterbury.ac.nz
Tue, 12 Jun 2001 11:51:55 +1200 (NZST)

Skip Montanaro <skip@pobox.com>:

> One thing that confused me a bit was
> that if 0.1 is approximated by something ever-so-slightly larger than 0.1,
> how is it that if you add ten of them together you wind up with a result
> that is ever-so-slightly less than 1.0?

I think what's happening is that the exact binary result 
of adding 0.1_plus_a_little to itself has one more bit than
there is room for, so it gets shifted right and one bit falls
off the end. The amount you lose when that happens a few times
ends up outweighing the extra that you would expect.

Whether it's worth trying to explain *that* in the tutorial
I don't know!

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg@cosc.canterbury.ac.nz	   +--------------------------------------+