summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2012-08-16 09:12:57 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2012-08-16 09:12:57 +0000
commit4a99bc9f436aab6b32f69c2b31405ce7f9493582 (patch)
tree6dce7774e0d04c93e51f68752dcd5f14cf0f3dde /tests
parenta8f16ece5772e418c7d1ffe6dd7da5f3301cf14c (diff)
downloadmpfr-4a99bc9f436aab6b32f69c2b31405ce7f9493582.tar.gz
[src/get_d64.c] mpfr_get_decimal64 was buggy in MPFR_RNDN on some
values x such that 0.5e-398 < |x| < 1e-398 (smallest subnormal): it was returning 0 instead of +/- 1e-398. [tests/tget_set_d64.c] Added testcases. (merged changesets r8370,8379 from the trunk) git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/branches/3.1@8380 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests')
-rw-r--r--tests/tget_set_d64.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/tget_set_d64.c b/tests/tget_set_d64.c
index 444307756..de35fba4e 100644
--- a/tests/tget_set_d64.c
+++ b/tests/tget_set_d64.c
@@ -289,6 +289,32 @@ check_overflow (void)
exit (1);
}
+static void
+check_tiny (void)
+{
+ mpfr_t x;
+ _Decimal64 d;
+
+ /* If 0.5E-398 < |x| < 1E-398 (smallest subnormal), x should round
+ to +/- 1E-398 in MPFR_RNDN. Note: the midpoint 0.5E-398 between
+ 0 and 1E-398 is not a representable binary number, so that there
+ are no tests for it. */
+ mpfr_init2 (x, 128);
+ mpfr_set_str (x, "1E-398", 10, MPFR_RNDZ);
+ d = mpfr_get_decimal64 (x, MPFR_RNDN);
+ MPFR_ASSERTN (d == 1.0E-398dd);
+ mpfr_neg (x, x, MPFR_RNDN);
+ d = mpfr_get_decimal64 (x, MPFR_RNDN);
+ MPFR_ASSERTN (d == -1.0E-398dd);
+ mpfr_set_str (x, "0.5E-398", 10, MPFR_RNDU);
+ d = mpfr_get_decimal64 (x, MPFR_RNDN);
+ MPFR_ASSERTN (d == 1.0E-398dd);
+ mpfr_neg (x, x, MPFR_RNDN);
+ d = mpfr_get_decimal64 (x, MPFR_RNDN);
+ MPFR_ASSERTN (d == -1.0E-398dd);
+ mpfr_clear (x);
+}
+
int
main (void)
{
@@ -306,6 +332,7 @@ main (void)
check_random ();
check_native ();
check_overflow ();
+ check_tiny ();
tests_end_mpfr ();
return 0;