summary refs log tree commit diff
path: root/math/test-misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'math/test-misc.c')
-rw-r--r--math/test-misc.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/math/test-misc.c b/math/test-misc.c
index 515277f5ad..c0b8d0ff77 100644
--- a/math/test-misc.c
+++ b/math/test-misc.c
@@ -39,6 +39,43 @@ main (void)
 	result = 1;
       }
   }
+
+# if __GNUC__ >= 3 || __GNUC_MINOR__ >= 96
+  {
+    long double x = LDBL_MAX / ldexpl (1.0L, LDBL_MANT_DIG + 1);
+    long double m;
+    int i;
+
+#  if LDBL_MANT_DIG == 64
+    m = 0xf.fffffffffffffffp-4L;
+#  else
+#   error "Please adjust"
+#  endif
+
+    for (i = 0; i < LDBL_MANT_DIG + 1; ++i, x *= 2.0L)
+      {
+	long double r;
+	int e;
+
+	printf ("2^%d: ", LDBL_MAX_EXP - (LDBL_MANT_DIG + 1) + i);
+
+	r = frexpl (x, &e);
+	if (r != m)
+	  {
+	    printf ("mantissa incorrect: %.20La\n", r);
+	    result = 1;
+	    continue;
+	  }
+	if (e != LDBL_MAX_EXP - (LDBL_MANT_DIG + 1) + i)
+	  {
+	    printf ("exponent wrong %d (%.20Lg)\n", e, x);
+	    result = 1;
+	    continue;
+	  }
+	puts ("ok");
+      }
+  }
+# endif
 #endif
 
   {