Wildemar Wildenburger wrote: > Ben Finney wrote: >> You most likely do *not* want floating-point numbers for currency, >> since they rely on the operating system's binary floating point >> support which cannot accurately represent decimal fractions. > > I've heard (ok, read) that several times now and I understand the > argument. But what use is there for floats, then? When is it OK to use them?
There are many, many situations where one is *not* trying to represent numbers that have nice decimal fractions or the error induced is insignificant to the problem. For example, I might take temperature readings good to 0.1 degrees Celcius. I'll type those numbers in decimal even though when I do my calculations I'll use floating point math because the error (about 1e-15 or so) is so far below the error in my measurement (about 0.1) that I won't have problems. Binary floating point has the advantage of being widely implemented and quite fast compared to decimal floating point. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list