GMP4.3.1, GCC 4.4.1 and denormalized double

Norbert Mueller mueller at uni-trier.de
Fri Oct 23 11:16:40 CEST 2009


There seems to be an error in the 64-bit verison of gmp 4.3.1 (or in gcc 
4.4.1.) when trying to convert from mpf to double in case the result is not 
normalized. For a detailed bug report see below.

Kind regards, 

Norbert
--------------------
gmp_version
	4.3.1

pre-packaged
	openSUSE 11.2 RC 1 (x86_64)
	(but same error for self-compiled versions)

test program   
###################gmp_check.c   ##############################
int main()
{
  double d1,d2;
  mpf_set_default_prec(64);
  mpf_t f;
  mpf_init(f);

  printf ("gmp_version=%s\n", gmp_version);
  printf ("VERSION=%d.%d.%d\n", __GNU_MP_VERSION, __GNU_MP_VERSION_MINOR,
          __GNU_MP_VERSION_PATCHLEVEL);

  d1=1.234e-315;
  mpf_set_d(f,d1);
  d2=mpf_get_d(f);

  printf("%e %e\n",d1,d2);
  mpf_clear (f);
}
############################################################
compilation:
	gcc -o gmp_check gmp_check.c -lgmp
running:
	./gmp_check
result:
	gmp_version=4.3.1
	VERSION=4.3.1
	1.234000e-315 1.192687e-314

description: 
	The conversion of a denormalized double (like to 1.234000e-315)
	to mpf and back gives a wrong result (here 1.192687e-314).
	The error seems to come from the conversion from mpf to double.

gcc -v
	gcc-Version 4.4.1 [gcc-4_4-branch revision 150839] (SUSE Linux)

uname -a
	Linux info14 2.6.31.3-1-default #1 SMP 2009-10-08 00:27:25 +0200 
		x86_64 x86_64 x86_64 GNU/Linux

---------------------------------------------------------------------
Remarks:
-	I know that gmp-4.3.1 and gcc-4.3.2 do not fit together.
	But this error here is for gcc-4.4.1.
-	"make check" for gmp-4.3.1 does not show any errors here.
-	gmp-4.2.x did not have this error
 


More information about the gmp-bugs mailing list