Re: [Python-Dev] Rounding float to int directly ...
Michael Chermside <mcherm@mcherm.com> wrote:
Decimal doesn't even help people who care about accuracy.
Not true! The float class is incapable of maintaining 700 digits of precision, but Decimal handles it just fine. (Why you would WANT more than around 53 bits of precision is a different question, but Decimal handles it.)
Oh, yes, the CURRENT decimal class is potentially more accurate than the CURRENT floating class, but that has nothing to do with the intrinsic differences in the base.
People who care about the accuracy of calculations prefer binary, as it is a more accurate model.
Huh? That doesn't even make sense! A model is not inherently accurate or inaccurate, it is only an accurate or inaccurate representation of some "real" system. Neither binary nor decimal is a better representation of either rational or real numbers, the first candidates for "real" system I thought of. Financial accounting rules tend to be based on paper-and-pencil calculations for which decimal is usually a far better representation.
If you had said that binary floats squeeze out more digits of precision per bit of storage than decimal floats, or that binary floats are faster because they are supported by specialized hardware, then I'd go along, but they're not a "better model".
No, that isn't true. The "wobbling precision" effect may be overstated, but is real, and gets worse the larger the base is. To the best of my knowledge, that is almost the only way in which binary is more accurate than decimal, in absolute terms, and it is a marginal difference. Note that I said "prefer", not "require" :-) For example, calculating the relative difference between two close numbers is sensitive to whether you are using the numbers in their normal or inverse forms (by a factor on N in base N), and this is a common cause of incorrect answers. A factor of 2 is better than one of 10. Regards, Nick Maclaren, University of Cambridge Computing Service, New Museums Site, Pembroke Street, Cambridge CB2 3QH, England. Email: nmm1@cam.ac.uk Tel.: +44 1223 334761 Fax: +44 1223 334679
participants (1)
-
Nick Maclaren