1-0.95
Marko Rauhamaa
marko at pacujo.net
Wed Jul 2 16:00:15 EDT 2014
Steven D'Aprano <steve+comp.lang.python at pearwood.info>:
>> >>> Rational(2).sqrt() * Rational(2).sqrt() == Rational(2)
>> False
>
> Square root of 2 is not a rational number.
Nobody said it was. It's just that even "arbitrary-precision" rational
numbers wouldn't free you from the issues of floating-point numbers. The
Decimal number class won't do it, either, of course.
On the other hand, floating-point numbers are perfect whenever you deal
with science and measurement. And when you deal with business (= money),
integers are the obvious choice.
I would venture to say that the real applications for Decimal are very
rare. In practice, I'm afraid, people with rather a weak understanding
of numbers and computation might gravitate toward Decimal unnecessarily.
Marko
More information about the Python-list
mailing list