[Tutor] Need more precise digits

Kirby Urner urnerk@qwest.net
Sat, 01 Dec 2001 17:17:40 -0800


>
> >>> float(1./2)
>0.5
> >>> float(1./3)
>0.33333333333333331
> >>> float(.1/3)
>0.033333333333333333
>
>Isn't the last one correct?
>
>Steve

Note:  it's reduntant to go float(1./2) as the decimal
point alone, after the numerator or the denominator,
is sufficient to make this a floating point operation.

  >>> .1/3
  0.033333333333333333

pushes the answer to the right by one decimal place,
so the trailing 1 drops off, but 0.33333333333333331 is
what binary math (vs. decimally based arithemetic)
really gives us -- i.e. this is all according to floating
point specifications.

Floating point numbers are not the same as real numbers.
They're actually "more real" in the sense of actually being
a part of the physical number crunching experience. No
one has ever multiplied pi x pi using a whole number based
positional representation without converting it from an
irrational to a rational number first.

Kirby