summaryrefslogtreecommitdiff
path: root/tests/tset_ld.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2005-04-21 09:32:22 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2005-04-21 09:32:22 +0000
commit6aa54abd415d64da2119552bdda2487b290cda3e (patch)
tree13fbb0476abffc7d415c3598317794f6201938d2 /tests/tset_ld.c
parent21175aa5eaebb5a4c4c99394f99605dee3ff0d52 (diff)
downloadmpfr-6aa54abd415d64da2119552bdda2487b290cda3e.tar.gz
Added test_small (the same as in the 2.1 branch).
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@3465 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tset_ld.c')
-rw-r--r--tests/tset_ld.c42
1 files changed, 41 insertions, 1 deletions
diff --git a/tests/tset_ld.c b/tests/tset_ld.c
index 15c2cf0c0..cfbab2ebc 100644
--- a/tests/tset_ld.c
+++ b/tests/tset_ld.c
@@ -88,6 +88,44 @@ check_set_get (long double d, mpfr_t x)
}
}
+static void
+test_small (void)
+{
+ mpfr_t x, y, z;
+ long double d;
+
+ mpfr_init2 (x, 64);
+ mpfr_init2 (y, 64);
+ mpfr_init2 (z, 64);
+
+ mpfr_set_str (x, "0.1010010100111100110000001110101101000111010110000001111101110011E-16381", 2, GMP_RNDN);
+ d = mpfr_get_ld (x, GMP_RNDN); /* infinite loop? */
+ mpfr_set_ld (y, d, GMP_RNDN);
+ mpfr_sub (z, x, y, GMP_RNDN);
+ mpfr_abs (z, z, GMP_RNDN);
+ mpfr_clear_erangeflag ();
+ if (mpfr_cmp_str (z, "1E-16434", 2, GMP_RNDN) > 0 || mpfr_erangeflag_p ())
+ {
+ printf ("Error with x = ");
+ mpfr_out_str (NULL, 10, 20, x, GMP_RNDN);
+ printf (" = ");
+ mpfr_out_str (NULL, 16, 0, x, GMP_RNDN);
+ printf ("\n -> d = %.20Lg", d);
+ printf ("\n -> y = ");
+ mpfr_out_str (NULL, 10, 20, y, GMP_RNDN);
+ printf (" = ");
+ mpfr_out_str (NULL, 16, 0, y, GMP_RNDN);
+ printf ("\n -> |x-y| = ");
+ mpfr_out_str (NULL, 16, 0, z, GMP_RNDN);
+ printf ("\n");
+ exit (1);
+ }
+
+ mpfr_clear (x);
+ mpfr_clear (y);
+ mpfr_clear (z);
+}
+
int
main (int argc, char *argv[])
{
@@ -133,7 +171,7 @@ main (int argc, char *argv[])
d = mpfr_get_ld (x, GMP_RNDN);
check_set_get (d, x);
- /* checks the largest power of two */
+ /* checks the largest power of two */
d = 1.0; while (d < LDBL_MAX / 2.0) d += d;
check_set_get (d, x);
check_set_get (-d, x);
@@ -183,6 +221,8 @@ main (int argc, char *argv[])
mpfr_clear (x);
+ test_small ();
+
tests_end_mpfr ();
return 0;