ANN: Experimental Number Types (Integer, Rational, Floats)
Paul Prescod
paulp at ActiveState.com
Thu Apr 19 15:19:53 EDT 2001
"M.-A. Lemburg" wrote:
>
>...
>
> from mx.Number import *
> f = Float(3.141)
> r1 = Rational(3.141)
> r2 = Rational(2, 3)
> i = Integer("1231231231231231231231231")
Wouldn't you more often make a rational from a string instead of a
float? The float loses precision and the rational loses performance so
you've got the worst of both worlds. :)
> * Please try out the rational type and see if it fits your
> needs -- the results are sometimes surprising (due to the
> IEEE representations of floats); I'm sure this proof of
> concept will raise a few more questions regarding the
> usefulness of switching to rationals for literals like
> 1.123.
This seems to come back to my point above. If you made the rational from
strings instead of floats, the IEEE representation for floats would be
irrelevant, wouldn't it?
--
Take a recipe. Leave a recipe.
Python Cookbook! http://www.ActiveState.com/pythoncookbook
More information about the Python-list
mailing list