[Python-numerics]Re: [Python-Dev] Re: WYSIWYG decimal fractions

Alex Martelli aleaxit@yahoo.com
Mon, 19 Mar 2001 00:26:23 +0100


"Tim Peters" <tim_one@email.msn.com> writes:

> Note that Alex Martelli runs the "General Multiprecision Python" project
on
> SourceForge:
>
>     http://gmpy.sourceforge.net/
>
> He had a severe need for fast rational arithmetic in his Python programs,
so
> starting wrapping the full GMP out of necessity.  I'm sorry to say that I
> haven't had time to even download his code.

...and as for me, I haven't gotten around to prettying it up for beta
release yet (mostly the docs -- still just a plain textfile) as it's doing
what I need... but, I _will_ get a round tuit...


> WRT floating point, GMP supports arbitrary-precision floats too, but not
in a
> way you're going to like:  they're binary floats, and do not deliver
> platform-independent results.  That last point is subtle, because the docs
> say:
>
>     The precision of a calculation is defined as follows:  Compute the
>     requested operation exactly (with "infinite precision"), and truncate
>     the result to the destination variable precision.
>
> Leaving aside that truncation is a bad idea, that *sounds*
> platform-independent.  The trap is that GMP supports no way to specify the
> precision of a float result exactly:  you can ask for any precision you
like,

There's another free library that interoperates with GMP to remedy
this -- it's called MPFR and lives at http://www.loria.fr/projets/mpfr/.
It's also LGPL.  I haven't looked much into it as it seems it's not been
ported to Windows yet (and that looks like quite a project) which is
the platform I'm currently using (and, rationals do what I need:-).

> > The existing mpz module only supports MP integers, but support
> > for the other two types should only be a matter of hard work ;-).
>
> Which Alex already did.  Now what <wink>?

Hmmm, port MPFR everywhere...?-)  Pearu Peterson already did the
MPFR Python wrapper interoperating with GMPY, btw -- it lives at
http://cens.ioc.ee/~pearu/misc/gmpy-mpfr/ (haven't tested it as
I can't run MPFR myself, as above explained).


Alex



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com