aboutsummaryrefslogtreecommitdiff
path: root/math
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2006-09-20 17:29:36 +0000
committerUlrich Drepper <drepper@redhat.com>2006-09-20 17:29:36 +0000
commit6624dbc07b5a9fb316ed188ef01f65b8eea8b47c (patch)
treed959e66afb360e3f4ef06bd5e20cffd7d10e2945 /math
parent60cb50c7b678a1cd2d794f134b81bea53dcf84b0 (diff)
downloadglibc-6624dbc07b5a9fb316ed188ef01f65b8eea8b47c.tar
glibc-6624dbc07b5a9fb316ed188ef01f65b8eea8b47c.tar.gz
glibc-6624dbc07b5a9fb316ed188ef01f65b8eea8b47c.tar.bz2
glibc-6624dbc07b5a9fb316ed188ef01f65b8eea8b47c.zip
[BZ #2592]
2006-06-17 Joseph S. Myers <joseph@codesourcery.com> [BZ #2592] * math/libm-test.inc (lrint_test_tonearest): New function. (lrint_test_towardzero): New function. (lrint_test_downward): New function. (lrint_test_upward): New function. (main): Run these new tests. * sysdeps/ieee754/dbl-64/s_llrint.c (__llrint): Correct rounding of values near to 0. (two52): Use double not long double. * sysdeps/ieee754/dbl-64/s_lrint.c (__lrint): Likewise. * sysdeps/ieee754/flt-32/s_llrintf.c (__llrintf): Likewise. (two23): Use float not double. * sysdeps/ieee754/flt-32/s_lrintf.c (__lrintf): Likewise. (two23): Use float not double. * sysdeps/ieee754/ldbl-128/s_llrintl.c (__llrintl): Likewise. * sysdeps/ieee754/ldbl-128/s_lrintl.c (__lrintl): Likewise. * sysdeps/ieee754/ldbl-96/s_llrintl.c (__llrintl): Likewise. * sysdeps/ieee754/ldbl-96/s_lrintl.c (__lrintl): Likewise.
Diffstat (limited to 'math')
-rw-r--r--math/libm-test.inc164
1 files changed, 164 insertions, 0 deletions
diff --git a/math/libm-test.inc b/math/libm-test.inc
index b99255fd6d..c27cc652ac 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -3273,6 +3273,166 @@ lrint_test (void)
static void
+lrint_test_tonearest (void)
+{
+ int save_round_mode;
+ START (lrint_tonearest);
+
+ save_round_mode = fegetround ();
+
+ if (!fesetround (FE_TONEAREST))
+ {
+ TEST_f_l (lrint, 0.0, 0);
+ TEST_f_l (lrint, minus_zero, 0);
+ TEST_f_l (lrint, 0.2L, 0);
+ TEST_f_l (lrint, -0.2L, 0);
+ TEST_f_l (lrint, 0.5L, 0);
+ TEST_f_l (lrint, -0.5L, 0);
+ TEST_f_l (lrint, 0.8L, 1);
+ TEST_f_l (lrint, -0.8L, -1);
+
+ TEST_f_l (lrint, 1.4L, 1);
+ TEST_f_l (lrint, -1.4L, -1);
+
+ TEST_f_l (lrint, 8388600.3L, 8388600);
+ TEST_f_l (lrint, -8388600.3L, -8388600);
+
+ TEST_f_l (lrint, 1071930.0008, 1071930);
+#ifndef TEST_FLOAT
+ TEST_f_l (lrint, 1073741824.01, 1073741824);
+# if LONG_MAX > 281474976710656
+ TEST_f_l (lrint, 281474976710656.025, 281474976710656);
+# endif
+#endif
+ }
+
+ fesetround (save_round_mode);
+
+ END (lrint_tonearest);
+}
+
+
+static void
+lrint_test_towardzero (void)
+{
+ int save_round_mode;
+ START (lrint_towardzero);
+
+ save_round_mode = fegetround ();
+
+ if (!fesetround (FE_TOWARDZERO))
+ {
+ TEST_f_l (lrint, 0.0, 0);
+ TEST_f_l (lrint, minus_zero, 0);
+ TEST_f_l (lrint, 0.2L, 0);
+ TEST_f_l (lrint, -0.2L, 0);
+ TEST_f_l (lrint, 0.5L, 0);
+ TEST_f_l (lrint, -0.5L, 0);
+ TEST_f_l (lrint, 0.8L, 0);
+ TEST_f_l (lrint, -0.8L, 0);
+
+ TEST_f_l (lrint, 1.4L, 1);
+ TEST_f_l (lrint, -1.4L, -1);
+
+ TEST_f_l (lrint, 8388600.3L, 8388600);
+ TEST_f_l (lrint, -8388600.3L, -8388600);
+
+ TEST_f_l (lrint, 1071930.0008, 1071930);
+#ifndef TEST_FLOAT
+ TEST_f_l (lrint, 1073741824.01, 1073741824);
+# if LONG_MAX > 281474976710656
+ TEST_f_l (lrint, 281474976710656.025, 281474976710656);
+# endif
+#endif
+ }
+
+ fesetround (save_round_mode);
+
+ END (lrint_towardzero);
+}
+
+
+static void
+lrint_test_downward (void)
+{
+ int save_round_mode;
+ START (lrint_downward);
+
+ save_round_mode = fegetround ();
+
+ if (!fesetround (FE_DOWNWARD))
+ {
+ TEST_f_l (lrint, 0.0, 0);
+ TEST_f_l (lrint, minus_zero, 0);
+ TEST_f_l (lrint, 0.2L, 0);
+ TEST_f_l (lrint, -0.2L, -1);
+ TEST_f_l (lrint, 0.5L, 0);
+ TEST_f_l (lrint, -0.5L, -1);
+ TEST_f_l (lrint, 0.8L, 0);
+ TEST_f_l (lrint, -0.8L, -1);
+
+ TEST_f_l (lrint, 1.4L, 1);
+ TEST_f_l (lrint, -1.4L, -2);
+
+ TEST_f_l (lrint, 8388600.3L, 8388600);
+ TEST_f_l (lrint, -8388600.3L, -8388601);
+
+ TEST_f_l (lrint, 1071930.0008, 1071930);
+#ifndef TEST_FLOAT
+ TEST_f_l (lrint, 1073741824.01, 1073741824);
+# if LONG_MAX > 281474976710656
+ TEST_f_l (lrint, 281474976710656.025, 281474976710656);
+# endif
+#endif
+ }
+
+ fesetround (save_round_mode);
+
+ END (lrint_downward);
+}
+
+
+static void
+lrint_test_upward (void)
+{
+ int save_round_mode;
+ START (lrint_upward);
+
+ save_round_mode = fegetround ();
+
+ if (!fesetround (FE_UPWARD))
+ {
+ TEST_f_l (lrint, 0.0, 0);
+ TEST_f_l (lrint, minus_zero, 0);
+ TEST_f_l (lrint, 0.2L, 1);
+ TEST_f_l (lrint, -0.2L, 0);
+ TEST_f_l (lrint, 0.5L, 1);
+ TEST_f_l (lrint, -0.5L, 0);
+ TEST_f_l (lrint, 0.8L, 1);
+ TEST_f_l (lrint, -0.8L, 0);
+
+ TEST_f_l (lrint, 1.4L, 2);
+ TEST_f_l (lrint, -1.4L, -1);
+
+ TEST_f_l (lrint, 8388600.3L, 8388601);
+ TEST_f_l (lrint, -8388600.3L, -8388600);
+
+#ifndef TEST_FLOAT
+ TEST_f_l (lrint, 1071930.0008, 1071931);
+ TEST_f_l (lrint, 1073741824.01, 1073741825);
+# if LONG_MAX > 281474976710656 && defined (TEST_LDOUBLE)
+ TEST_f_l (lrint, 281474976710656.025, 28147497671065);
+# endif
+#endif
+ }
+
+ fesetround (save_round_mode);
+
+ END (lrint_upward);
+}
+
+
+static void
llrint_test (void)
{
/* XXX this test is incomplete. We need to have a way to specifiy
@@ -5937,6 +6097,10 @@ main (int argc, char **argv)
rint_test_downward ();
rint_test_upward ();
lrint_test ();
+ lrint_test_tonearest ();
+ lrint_test_towardzero ();
+ lrint_test_downward ();
+ lrint_test_upward ();
llrint_test ();
llrint_test_tonearest ();
llrint_test_towardzero ();