summaryrefslogtreecommitdiff
path: root/tests/tests.c
diff options
context:
space:
mode:
authorryde <ryde@280ebfd0-de03-0410-8827-d642c229c3f4>2003-01-08 21:00:32 +0000
committerryde <ryde@280ebfd0-de03-0410-8827-d642c229c3f4>2003-01-08 21:00:32 +0000
commit73f49c5c4b6ccb2d8ee166821b6812d0bca5cf27 (patch)
treec1362ab976c3c0be2e0b4eef9bd3b57094e29825 /tests/tests.c
parenta3e2facd159649c83c09c8b0a6a760a78774d795 (diff)
downloadmpfr-73f49c5c4b6ccb2d8ee166821b6812d0bca5cf27.tar.gz
(tests_machine_prec_double, tests_machine_prec_long_double): New functions.
(mpfr_test_init): Replace __setfpucw with tests_machine_prec_double. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2146 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tests.c')
-rw-r--r--tests/tests.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/tests/tests.c b/tests/tests.c
index 0235f6a32..dfd78f292 100644
--- a/tests/tests.c
+++ b/tests/tests.c
@@ -85,10 +85,8 @@ mpfr_test_init ()
}
#endif
-#ifdef HAVE_SETFPUCW
- /* sets the precision to double */
- __setfpucw((_FPU_DEFAULT & (~_FPU_EXTENDED)) | _FPU_DOUBLE);
-#endif
+ tests_machine_prec_double ();
+
c = 1.46484375e-3;
d = 1.0;
for (j=0; j<54; j++) d *= 0.5;
@@ -101,6 +99,32 @@ mpfr_test_init ()
}
}
+
+/* Set the machine floating point precision, to double or long double.
+
+ On i386 this controls the mantissa precision on the x87 stack, but the
+ exponent range is only enforced when storing to memory.
+
+ For reference, on most i386 systems the default is 64-bit "long double"
+ precision, but on FreeBSD 3.x it's 53-bit "double". */
+
+void
+tests_machine_prec_double (void)
+{
+#if MPFR_HAVE_TESTS_x86
+ x86_fldcw ((x86_fstcw () & ~0x300) | 0x200);
+#endif
+}
+
+void
+tests_machine_prec_long_double (void)
+{
+#if MPFR_HAVE_TESTS_x86
+ x86_fldcw (x86_fstcw () | 0x300);
+#endif
+}
+
+
/* generate a random double using the whole range of possible values,
including denormalized numbers, NaN, infinities, ... */
double