mpf_get_d

Paul Zimmermann Paul.Zimmermann at loria.fr
Tue Dec 15 13:47:14 CET 2009


       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;
}


More information about the gmp-bugs mailing list