On Feb 17, 4:25 am, Carl Banks <[EMAIL PROTECTED]> wrote: > On Feb 16, 3:03 pm, Lie <[EMAIL PROTECTED]> wrote: > > > Although rationals have its limitations too, it is a much > > better choice compared to floats/Decimals for most cases. > > Maybe that's true for your use cases, but it's not true for most cases > in general.
OK, that might have been an overstatement, but as I see it, it is safer to handle something in a Fraction compared to floats (which is why I uses fractions whenever possible in non-computer maths). > Rationals are pretty useless for almost any extended calculations, > since the denominator tends to grow in size till it's practically > unusbale, which means you have to periodically do non-exact reductions > to keep things running, and if you do that you might as well be using > floating point. Rationals aren't that good if the same piece of variable is to be calculated again and again because of its growth, but there are a lot of cases where the data would only require five or six or so operations done on it (and there are thousands or millions of such datas), rationals is the perfect choice for those situations because it is easier to use thanks to the comparison safety. Or in the situations where speed isn't as important and accuracy is required, Fraction may be faster than decimal and more accurate at the same time (someone need to test that though). > Rationals have their occasional special purpose uses, but for most > cases they're at best marginally better then floats and more often > incomparably worse. -- http://mail.python.org/mailman/listinfo/python-list