mpf_get_d
Torbjorn Granlund
tg at gmplib.org
Tue Dec 15 14:27:53 CET 2009
Paul Zimmermann <Paul.Zimmermann at loria.fr> writes:
Hi,
it seems mpf_get_d does not truncate its input in the subnormal range.
See the example program below. On a 64-bit Core 2 under Fedora Core 12,
I get:
tarte% ./bug3
lib: 4.3.1
include: 4.3.1
0.25903268932681546e-317
d=1.0612569276778973e-314
Paul
#include <stdio.h>
#include <stdlib.h>
#include "gmp.h"
int
main()
{
mpf_t a;
double d;
printf ("lib: %s\n", gmp_version);
printf ("include: %d.%d.%d\n", __GNU_MP_VERSION,
__GNU_MP_VERSION_MINOR, __GNU_MP_VERSION_PATCHLEVEL);
mpf_init2 (a, 1024);
mpf_set_str (a, "0.25903268932681546e-317", 10);
mpf_out_str (stdout, 10, 0, a); printf ("\n");
d = mpf_get_d (a);
printf ("d=%.16e\n", d);
mpf_clear (a);
return 0;
}
This was fixed a while ago:
http://shell.gmplib.org:8000/gmp-4.3/rev/32cc41c2fdea
Please try the patch.
(GMP 4.3.2 should be released within a few days, with this fix, as well
as an important fix to FFT multiplication.)
--
Torbjörn
More information about the gmp-bugs
mailing list