summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rint.c12
-rw-r--r--tests/tget_sj.c6
2 files changed, 12 insertions, 6 deletions
diff --git a/rint.c b/rint.c
index 4c7f2d4b8..5b63b2b32 100644
--- a/rint.c
+++ b/rint.c
@@ -60,8 +60,8 @@ mpfr_rint (mpfr_ptr r, mpfr_srcptr u, mpfr_rnd_t rnd_mode)
rnd_mode == GMP_RNDD ? sign < 0 :
rnd_mode == GMP_RNDU ? sign > 0 :
rnd_mode == GMP_RNDZ ? 0 :
- rnd_mode == GMP_RNDN ? -1 :
- 1; /* round to away */
+ rnd_mode == GMP_RNDA ? 1 :
+ -1; /* round to nearest-even (RNDN) or nearest-away (RNDNA) */
/* rnd_away:
1 if round away from zero,
@@ -304,7 +304,7 @@ mpfr_rint (mpfr_ptr r, mpfr_srcptr u, mpfr_rnd_t rnd_mode)
int
mpfr_round (mpfr_ptr r, mpfr_srcptr u)
{
- return mpfr_rint(r, u, GMP_RNDNA);
+ return mpfr_rint (r, u, GMP_RNDNA);
}
#undef mpfr_trunc
@@ -312,7 +312,7 @@ mpfr_round (mpfr_ptr r, mpfr_srcptr u)
int
mpfr_trunc (mpfr_ptr r, mpfr_srcptr u)
{
- return mpfr_rint(r, u, GMP_RNDZ);
+ return mpfr_rint (r, u, GMP_RNDZ);
}
#undef mpfr_ceil
@@ -320,7 +320,7 @@ mpfr_trunc (mpfr_ptr r, mpfr_srcptr u)
int
mpfr_ceil (mpfr_ptr r, mpfr_srcptr u)
{
- return mpfr_rint(r, u, GMP_RNDU);
+ return mpfr_rint (r, u, GMP_RNDU);
}
#undef mpfr_floor
@@ -328,7 +328,7 @@ mpfr_ceil (mpfr_ptr r, mpfr_srcptr u)
int
mpfr_floor (mpfr_ptr r, mpfr_srcptr u)
{
- return mpfr_rint(r, u, GMP_RNDD);
+ return mpfr_rint (r, u, GMP_RNDD);
}
#undef mpfr_rint_round
diff --git a/tests/tget_sj.c b/tests/tget_sj.c
index 51c293f1d..40de1b601 100644
--- a/tests/tget_sj.c
+++ b/tests/tget_sj.c
@@ -79,6 +79,9 @@ check_sj (intmax_t s, mpfr_ptr x)
continue;
if (rnd == GMP_RNDU && i > 0)
continue;
+ if (rnd == GMP_RNDA && ((MPFR_IS_POS(y) && i > 0) ||
+ (MPFR_IS_NEG(y) && i < 0)))
+ continue;
/* rint (y) == x == s */
r = mpfr_get_sj (y, (mp_rnd_t) rnd);
if (r != s)
@@ -119,6 +122,9 @@ check_uj (uintmax_t u, mpfr_ptr x)
continue;
if (rnd == GMP_RNDU && i > 0)
continue;
+ if (rnd == GMP_RNDA && ((MPFR_IS_POS(y) && i > 0) ||
+ (MPFR_IS_NEG(y) && i < 0)))
+ continue;
/* rint (y) == x == u */
r = mpfr_get_uj (y, (mp_rnd_t) rnd);
if (r != u)