On Feb 14, 8:10 pm, Zentrader <[EMAIL PROTECTED]> wrote:
> > That's a misconception. The decimal-module has a different base (10
> > instead of 2), and higher precision. But that doesn't change the fact
> > that it will expose the same rounding-errors as floats do - just for
> > different numbers.
>
> >  >>> import decimal as d
> >  >>> d = d.Decimal
> >  >>> d("1") / d("3") * d("3")
> > Decimal("0.9999999999999999999999999999")
>
> Surely you jest.

He's not joking at all.

> Your example is exact to 28 digits.  Your attempted
> trick is to use a number that never ends (1/3=0.3333...).

It does end in base 3, 6, 9, 12, etc.

You have to remember that base-ten wasn't chosen because it has
mathematical advantages over other bases, but merely because people
counted on their fingers.  In light of this fact, why is one-fifth
more deserving of an exact representation than one-third is?
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to