Using fractions instead of floats

mensanator at aol.com mensanator at aol.com
Tue Oct 2 19:14:14 EDT 2007


On Oct 2, 5:43 pm, richy... at gmail.com wrote:
> On Oct 2, 5:27 pm, "mensana... at aol.com" <mensana... at aol.com> wrote:
>
> > But it is still wrong to say "0.6 is definitely not the same as 3/5".
>
> Out of context, I'd certainly agree.  But from the context, I assumed
> it was clear that the 0.6 was a Python float.  I probably should have
> made this clearer.  My statement should probably have been something
> like: a literal 0.6 in Python code does not have the same mathematical
> value as the rational (or real) number 3/5.

Ok, so maybe I should have said: the literal 0.6 isn't what gets added
to mpq(1,3) to form the sum. What actually is added is the 0.6 coerced
to an mpq which is then added to mpq(1,3). So what 0.6 is as a float
is
relevent only to what it gets coerced to.

>
> Richard





More information about the Python-list mailing list