Using fractions instead of floats

andresj at
Tue Oct 2 02:09:25 CEST 2007

> > On 2007-10-01, Arnaud Delobelle <arno... at> wrote:
> > > Finally, arithmetic would become very confusing if there were
> > > three distinct numeric types; it already causes enough
> > > confusion with two!

Well, yeah... I get what you are saying, that would be confusing...

Terry Reedy and Laurent Pointal:
I know from __future__ import division changes the behaivour to return
floats instead of ints, but what I meant is to be able to implement a
function (or class/method) which would return what _I_ want/decide.

Gabriel Genellina, thanks for the suggestion of wrapping my code. I
think it could be one way... But I think it would be too much trouble,
I'll just go with writing fractions/rationals explicitly.

And thanks to mensanator and Gabriel for the suggestion of gmpy, and
to Nick for the example (It really helps to have an example, because
it usually takes me hours to get to what I want in the
documentations :). I think I will use that, when i get it working in
Ubuntu. Do you guys know of any pre-made package or guides for getting
it working in Ubuntu?

Well, I guess my idea was not as good as I thought it was :). But
anyways... I look forward to Python 3.0 (Specially the
__future__.with_statement and the standardization of names-- cStringIO
is just too ugly for my eyes!)

More information about the Python-list mailing list