aboutsummaryrefslogtreecommitdiff
path: root/math
diff options
context:
space:
mode:
authorAdhemerval Zanella <azanella@linux.vnet.ibm.com>2012-05-10 15:11:55 -0500
committerRyan S. Arnold <rsa@linux.vnet.ibm.com>2012-05-10 15:11:55 -0500
commit89c9aa491a7cee97bf78a29cddbf0a25c902a671 (patch)
treea03f7f7a4864421a67c1f4ba3c4ad74090cc0e63 /math
parent021db4be6f1f4189f66feee066a495d49e92b93e (diff)
downloadglibc-89c9aa491a7cee97bf78a29cddbf0a25c902a671.zip
glibc-89c9aa491a7cee97bf78a29cddbf0a25c902a671.tar.gz
glibc-89c9aa491a7cee97bf78a29cddbf0a25c902a671.tar.bz2
Fix for logb/logbf/logbl (bugs 13954/13955/13956)
POSIX 2008 states that if the input for 'logb[f|l]' is a subnormal number it should be treated as if it were normalized. This means the implementation should calculate the log2 of the mantissa and add it to the subnormal exponent (-126 for float and -1022 for double and IBM long double). This patch takes care of that.
Diffstat (limited to 'math')
-rw-r--r--math/libm-test.inc16
1 files changed, 16 insertions, 0 deletions
diff --git a/math/libm-test.inc b/math/libm-test.inc
index 542131d..5a38dbf 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -5376,6 +5376,22 @@ logb_test (void)
TEST_f_f (logb, 1024, 10);
TEST_f_f (logb, -2000, 10);
+ TEST_f_f (logb, 0x0.1p-127, -131);
+ TEST_f_f (logb, 0x0.01p-127, -135);
+ TEST_f_f (logb, 0x0.011p-127, -135);
+#ifndef TEST_FLOAT
+ TEST_f_f (logb, 0x0.8p-1022, -1023);
+ TEST_f_f (logb, 0x0.1p-1022, -1026);
+ TEST_f_f (logb, 0x0.00111p-1022, -1034);
+ TEST_f_f (logb, 0x0.00001p-1022, -1042);
+ TEST_f_f (logb, 0x0.000011p-1022, -1042);
+ TEST_f_f (logb, 0x0.0000000000001p-1022, -1074);
+#endif
+#if defined TEST_LDOUBLE && LDBL_MIN_EXP - LDBL_MANT_DIG <= -16400
+ TEST_f_f (logb, 0x1p-16400L, -16400);
+ TEST_f_f (logb, 0x.00000000001p-16382L, -16426);
+#endif
+
END (logb);
}