PEP 327: Decimal Data Type

Batista, Facundo FBatista at uniFON.com.ar
Mon Feb 2 09:45:32 EST 2004


danb_83 wrote: 

#- On the other hand, when I say that I am 1.80 m tall, it doesn't imply
#- that humans height comes in discrete packets of 0.01 m.  It 
#- means that
#- I'm *somewhere* between 1.795 and 1.805 m tall, depending on my
#- posture and the time of day, and "1.80" is just a convenient
#- approximation.  And it wouldn't be inaccurate to express my height as
#- 0x1.CC (=1.796875) or (base 12) 1.97 (=1.7986111...) meters, because
#- these are within the tolerance of the measurement.  So number base
#- doesn't matter here.

Are you saying that it's ok to store your number imprecisely because you
don't take well measures?


#- But even if the number base of a measurement doesn't matter, 
#- precision
#- and speed of calculations often does.  And on digital computers,
#- non-binary arithmetic is inherently imprecise and slow.  Imprecise
#- because register bits are limited and decimal storage wastes them. 
#- (For example, representing the integer 999 999 999 requires 
#- 36 bits in
#- BCD but only 30 bits in binary.  Also, for floating point, 
#- only binary
#- allows the precision-gaining "hidden bit" trick.)  Slow because
#- decimal requires more complex hardware.  (For example, a BCD 
#- adder has
#- more than twice as many gates as a binary adder.)

In my dreams, speed and storage are both infinite, :p

.	Facundo




More information about the Python-list mailing list