This math scares me

Grant Edwards grante at visi.com
Mon Mar 12 17:53:19 EST 2001


In article <DZbr6.17917$Qb7.3117518 at newsb.telia.net>, Fredrik Lundh wrote:
>costas at springmail.com wrote:
>> I will also tell my customers that this is the new math.
>
>if you don't understand how floating point numbers work, you
>probably shouldn't use them in customer projects.

Fredrik is right.  Using floating point numbers requires that
you know what you're doing.  They are _not_ exact.  If your
customers are expecting exact results and you're using floating
point numbers, then you did a bad thing.

People should have to pass a test before they're allowed to use
floating point numbers.    1/2 ;)

Do _not_ use floating point numbers for currency.  Use integers
or fixed point BCD.  Use floating point numbers to represent
quantities that vary continuously and are not known exactly:
the temperature outside, the length of a piece of string, etc.

-- 
Grant Edwards                   grante             Yow!  Where do your SOCKS
                                  at               go when you lose them in
                               visi.com            th' WASHER?



More information about the Python-list mailing list