Karim Belabas on Wed, 05 Oct 2005 18:27:56 +0200


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

Re: Fwd: Incorrect conversion of unnormalized IEEE doubles


* Bill Allombert [2005-10-05 14:12]:
> On Wed, Oct 05, 2005 at 07:15:51AM -0400, kynn@panix.com wrote:
> > I was not able to find mention of this bug at
> > http://pari.math.u-bordeaux.fr/Bugs/, 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".
> 
> pari-stable denotes version 2.1.x, pari denotes version 2.2.x.
> The latest stable version is 2.1.7.
> 
> > 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.
> 
> I think I can reproduce this bug with all versions (2.1.3, 2.1.7,
> 2.2.11) by using the C program below:
> 
> --------------
> #include <pari/pari.h>
> #include <float.h>
> 
> int main(void)
> {
>   double g=DBL_MIN/2;
>   GEN z;
>   pari_init(4000000,2);
>   z=dbltor(g);
>   pariputsf("%g %Z\n",g,z);
> }

I have committed a patch to CVS, which should treat properly unnormalized
numbers (and also recognize NaN and +/-Infinity, if only by raising an
error instead of returning junk).

It looks OK on 32 and 64 bit machines.

Thanks for the bug report and analysis!

    Karim.
-- 
Karim Belabas                  Tel: (+33) (0)5 40 00 26 17
Universite Bordeaux 1          Fax: (+33) (0)5 40 00 69 50
351, cours de la Liberation    http://www.math.u-bordeaux.fr/~belabas/
F-33405 Talence (France)       http://pari.math.u-bordeaux.fr/  [PARI/GP]