[Tutor] Float Numbers. 98/100 returns 0.97999999999999998

Jethro Cramp jsc_lists@rock-tnsc.com
Wed, 28 Mar 2001 12:50:16 +0800


> -----Original Message-----
> From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
> Remco Gerlich
> Sent: Wednesday, March 21, 2001 6:31 PM
> To: tutor@python.org
> Subject: Re: [Tutor] Float Numbers. 98/100 returns 0.97999999999999998
>

>
> Hmm, there is a small fixed decimal precision arithmetic library called
> FixedPoint that you probably want to use, see FixedPoint.py and .README in
> ftp://ftp.python.org/pub/python/contrib-09-Dec-1999/DataStructures/ .
>
Remco,

Thanks for the info. I finally got around to trying to use FixedPoint today.
However when I tested it in the python interpreter I found some very weird
results:

>>> x = FixedPoint("5.55")
>>> print x
.05

According to the docstrings the above should produce the result:
>>> x = FixedPoint("5.55")  # precision defaults to 2
>>> print x
5.55

I am using Python 2.0. Could this be caused by differences between 1.5.2 and
2.0?

Anyother hints?

TIA,

Jethro