floating point arithmetic

Mensanator mensanator at aol.com
Tue Aug 26 17:20:24 EDT 2008


On Aug 26, 4:11 pm, fred8865 <xtd8... at gmail.com> wrote:
> Hi all,
>
> I understand that due to different arithmetic used in floating points
> they are just approximations. Hence, 180/100=1 in my python interpreter.
> How can I tackle this problem of inaccurate floating point numbers?

Try actually using floating point numbers, not integers:

>>> 180.0/100
1.8

or

>>> float(180)/100
1.8


> thank you
>
> regards
> xtd




More information about the Python-list mailing list