floating point in 2.0

Chris Barker chrishbarker at home.net
Tue Jun 5 19:22:19 CEST 2001


Aahz Maruch wrote:
> Actually, 2.0 *still* lies:
> 
> >>> 0.1
> 0.10000000000000001
> >>> '%.55f' % 0.1
> '0.1000000000000000055511151231257827021181583404541015625'
> 
> It just lies less than it used to.

What the heck are all those digits at the end? Talk about lies, you can
be sure all those digits aren't being stored (at least not in an IEEE
754 64bit double, which stores approx. 16 decimal digits. Approx.
because it is really a given number of binary digits. I don't have the
exact number off of the top of my head).

interestingly enough, If you try to diplay more, you get:
>>> '%.70f' % 0.1
'0.1000000000000000055511151231257827021181583404541015625000000000000000'

now the extra is all zeros. Also, I get the same 55 digtits, so theya re
not random garbage. Does anyone know what they are? Perhaps the Intel
extra precision FPU bits?

-Chris


-- 
Christopher Barker,
Ph.D.                                                           
ChrisHBarker at home.net                 ---           ---           ---
http://members.home.net/barkerlohmann ---@@       -----@@       -----@@
                                   ------@@@     ------@@@     ------@@@
Oil Spill Modeling                ------   @    ------   @   ------   @
Water Resources Engineering       -------      ---------     --------    
Coastal and Fluvial Hydrodynamics --------------------------------------
------------------------------------------------------------------------



More information about the Python-list mailing list