IEEE 754

Edward Jason Riedy ejr at lotus.CS.Berkeley.EDU
Mon Jul 24 19:09:30 EDT 2000


And John W. Baxter writes:
 - 
 - You mean I may someday be able to put aside my answers to the "why 
 - doesn't 2/10 print as 0.2 as we all know it should?" sorts of questions?

I wish.  IEEE 854 is a radix-independent FP standard.  It could be
implemented for base-10 in hardware, but only some hand calculators 
have done that.  There are many libraries for BCD-style arithmetic, 
but I don't know how good or fast they are.  I don't understand all 
the issues involved.

Way off-topic:  Besides, not all numbers are natural for base-10.  
One example is pi.  It strongly appears that the only natural base 
for pi is 16 (pi may be base-16 normal and not base-10 normal).  Not 
proven yet, but looking likely.  See 
http://www.nersc.gov/~dhbailey/dhbpapers/bcrandom.ps for some neat
pi results.

Back on topic:  Python's answer is even more painful to explain:
> bash-2.03$ python -c 'print 2/10'
> 0

Jason



More information about the Python-list mailing list