aboutsummaryrefslogtreecommitdiff
path: root/math/libm-test.inc
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2012-03-05 12:22:46 +0000
committerJoseph Myers <joseph@codesourcery.com>2012-03-05 12:22:46 +0000
commitb7cd39e8f8c5cf2844f20eb03f545d19c4c25987 (patch)
tree1b6c55bdacf30fe15197282cf5d556fe708266ed /math/libm-test.inc
parentca811b2256d2e48c7288219e9e11dcbab3000f19 (diff)
downloadglibc-b7cd39e8f8c5cf2844f20eb03f545d19c4c25987.tar
glibc-b7cd39e8f8c5cf2844f20eb03f545d19c4c25987.tar.gz
glibc-b7cd39e8f8c5cf2844f20eb03f545d19c4c25987.tar.bz2
glibc-b7cd39e8f8c5cf2844f20eb03f545d19c4c25987.zip
Fix pow in non-default rounding modes (bug 3976).
Diffstat (limited to 'math/libm-test.inc')
-rw-r--r--math/libm-test.inc109
1 files changed, 109 insertions, 0 deletions
diff --git a/math/libm-test.inc b/math/libm-test.inc
index 684955ef5f..9bdbc4cb98 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -5318,6 +5318,111 @@ pow_test (void)
END (pow);
}
+
+static void
+pow_test_tonearest (void)
+{
+ int save_round_mode;
+ errno = 0;
+ FUNC(pow) (0, 0);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (pow_tonearest);
+
+ save_round_mode = fegetround ();
+
+ if (!fesetround (FE_TONEAREST))
+ {
+ TEST_ff_f (pow, 1.0625L, 1.125L, 1.070582293028761362162622578677070098674L);
+ TEST_ff_f (pow, 1.5L, 1.03125L, 1.519127098714743184071644334163037684948L);
+ }
+
+ fesetround (save_round_mode);
+
+ END (pow_tonearest);
+}
+
+
+static void
+pow_test_towardzero (void)
+{
+ int save_round_mode;
+ errno = 0;
+ FUNC(pow) (0, 0);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (pow_towardzero);
+
+ save_round_mode = fegetround ();
+
+ if (!fesetround (FE_TOWARDZERO))
+ {
+ TEST_ff_f (pow, 1.0625L, 1.125L, 1.070582293028761362162622578677070098674L);
+ TEST_ff_f (pow, 1.5L, 1.03125L, 1.519127098714743184071644334163037684948L);
+ }
+
+ fesetround (save_round_mode);
+
+ END (pow_towardzero);
+}
+
+
+static void
+pow_test_downward (void)
+{
+ int save_round_mode;
+ errno = 0;
+ FUNC(pow) (0, 0);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (pow_downward);
+
+ save_round_mode = fegetround ();
+
+ if (!fesetround (FE_DOWNWARD))
+ {
+ TEST_ff_f (pow, 1.0625L, 1.125L, 1.070582293028761362162622578677070098674L);
+ TEST_ff_f (pow, 1.5L, 1.03125L, 1.519127098714743184071644334163037684948L);
+ }
+
+ fesetround (save_round_mode);
+
+ END (pow_downward);
+}
+
+
+static void
+pow_test_upward (void)
+{
+ int save_round_mode;
+ errno = 0;
+ FUNC(pow) (0, 0);
+ if (errno == ENOSYS)
+ /* Function not implemented. */
+ return;
+
+ START (pow_upward);
+
+ save_round_mode = fegetround ();
+
+ if (!fesetround (FE_UPWARD))
+ {
+ TEST_ff_f (pow, 1.0625L, 1.125L, 1.070582293028761362162622578677070098674L);
+ TEST_ff_f (pow, 1.5L, 1.03125L, 1.519127098714743184071644334163037684948L);
+ }
+
+ fesetround (save_round_mode);
+
+ END (pow_upward);
+}
+
+
static void
remainder_test (void)
{
@@ -7218,6 +7323,10 @@ main (int argc, char **argv)
fabs_test ();
hypot_test ();
pow_test ();
+ pow_test_tonearest ();
+ pow_test_towardzero ();
+ pow_test_downward ();
+ pow_test_upward ();
sqrt_test ();
/* Error and gamma functions: */