kynn on Wed, 05 Oct 2005 13:22:38 +0200

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Fwd: Incorrect conversion of unnormalized IEEE doubles

In our lab we use PARI via the Perl module Math::Pari.  Recently I
discovered a bug in the way the Math::Pari::PARI function converts
unnormalized IEEE doubles into PARI reals (see bug report below, and
also at the listed URL).

The author of Math::Pari (Ilya Zakharevich) is of the opinion that the
bug is in the underlying PARI library (see correspondence below).

I was not able to find mention of this bug at, but on the other hand I was not
able to determine what versions numbers correspond to the
"pari-stable" and "pari" options in that page, so it is possible that
the version I am using, which is quite old (2.1.3), is not covered in
these bug reports and that the bug I'm referring to was already
fixed in "pari-stable".

Anyway, if any of you is able to reproduce the bug in the PARI
versions corresponding to the "pari-stable" or "pari" options, please
let me know, and I'll send in a formal bug report.

You can find more details about my machine's architecture, OS, etc.,




Subject: Re: [cpan #14891] Incorrect conversion of unnormalized IEEE doubles
From: "Ilya Zakharevich via RT" <>
RT-Ticket: cpan #14891
Date: Tue,  4 Oct 2005 21:58:07 -0400 (EDT)

Full context and any attached attachments can be found at:
<URL: >

On Mon, Oct 03, 2005 at 12:19:11PM -0400, via RT wrote:
> Math::Pari produces wrong results when it converts unnormalized IEEE
> doubles to PARI reals.  For example
>   print POSIX::DBL_MIN()/2
>   1.1125369292536e-308
> ...while
>   print Math::Pari::PARI( POSIX::DBL_MIN()/2 )
>   1.668805393880401037E-308
> ...which is actually POSIX::DBL_MIN*(3/4).  This represents a relative
> error of 50%, which is far from negligible.
> It appears that Math::Pari::PARI is converting numbers of the form
>   POSIX::DBL_MIN()/2**$n
> (where $n is a positive integer) into numbers of the form
>   POSIX::DBL_MIN()*((2**$n)-1)/(2**(-$n-1))

Thanks for a great bug report?  Could you also produce a great bug
fix? ;-)

The problem is (IIRC) that Math::Pari uses a PARI API which
(apparently) is very rarely used otherwise.  So I would think it is a
GP/PARI bug exposed by Math::Pari...

------- End of forwarded message -------