PEP 327: Decimal Data Type

David M. Cooke cookedm+news at physics.mcmaster.ca
Mon Feb 2 17:07:52 EST 2004


At some point, "Batista, Facundo" <FBatista at uniFON.com.ar> wrote:

> 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?

What we need for this is an interval type. 1.80 m shouldn't be stored
as '1.80', but as '1.80 +/- 0.005', and operations such as addition
and multiplication should propogate the intervals.

How to do that is another question: for addition, do you add the
magnitudes of the intervals, or use the square root of the sums of the
squares, or something else? It greatly depends on what _type_ of error
0.005 measures (is it the width of a Gaussian distribution? a uniform
distribution? something skewed that's not representable by one
number?).

My 0.0438126 Argentina pesos [1]

[1] $0.02 Canadian, which hilights the other problem with any
representation of a number without units -- decimal or otherwise.

-- 
|>|\/|<
/--------------------------------------------------------------------------\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca



More information about the Python-list mailing list