summaryrefslogtreecommitdiff
path: root/tests/tui_div.c
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2002-03-26 18:39:57 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2002-03-26 18:39:57 +0000
commitb6ca46407474e07a435ec12b45dc77e067ff6779 (patch)
treec646f424e87e47b64f46d65670ec564f9c206cdf /tests/tui_div.c
parent966581fea9ed11672ce12db8436d8bd72fa47e95 (diff)
downloadmpfr-b6ca46407474e07a435ec12b45dc77e067ff6779.tar.gz
- use mpfr_test_init to initialize harware floats
- use #ifdef HAVE_INFS when using DBL_NAN, ... - fixed some problems with wrongly converted f-p values (esp. under IRIX) git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@1783 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tui_div.c')
-rw-r--r--tests/tui_div.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/tests/tui_div.c b/tests/tui_div.c
index 4d58735d9..bb990d5d9 100644
--- a/tests/tui_div.c
+++ b/tests/tui_div.c
@@ -22,6 +22,7 @@ MA 02111-1307, USA. */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
+#include <time.h>
#include "gmp.h"
#include "gmp-impl.h"
#include "mpfr.h"
@@ -43,7 +44,7 @@ check (unsigned long y, double x, mp_rnd_t rnd_mode, double z1)
mpfr_init2(zz, 53);
mpfr_set_d(xx, x, rnd_mode);
mpfr_ui_div(zz, y, xx, rnd_mode);
-#ifdef TEST
+#ifdef HAVE_FENV
mpfr_set_machine_rnd_mode(rnd_mode);
#endif
if (z1==0.0) z1 = y/x;
@@ -151,29 +152,27 @@ check_nan (void)
int
main (int argc, char *argv[])
{
-#ifdef TEST
- {
- double x; unsigned long y, N; int i,rnd_mode,rnd;
-#ifdef __mips
- /* to get denormalized numbers on IRIX64 */
- union fpc_csr exp;
- exp.fc_word = get_fpc_csr();
- exp.fc_struct.flush = 0;
- set_fpc_csr(exp.fc_word);
-#endif
+#ifdef HAVE_FENV
+ double x;
+ unsigned long y, N;
+ int i, rnd_mode, rnd;
+
+ mpfr_test_init ();
SEED_RAND(time(NULL));
N = (argc<2) ? 1000000 : atoi(argv[1]);
rnd_mode = (argc<3) ? -1 : atoi(argv[2]);
- for (i=0;i<1000000;i++) {
- x = drand();
- y = LONG_RAND();
- if (ABS(x)>4e-286) {
- /* avoid denormalized numbers and overflows */
- rnd = (rnd_mode==-1) ? LONG_RAND()%4 : rnd_mode;
- check(y, x, rnd, 0.0);
+ for (i=0;i<1000000;i++)
+ {
+ x = drand();
+ y = LONG_RAND();
+ if (ABS(x)>4e-286)
+ {
+ /* avoid denormalized numbers and overflows */
+ rnd = (rnd_mode==-1) ? LONG_RAND()%4 : rnd_mode;
+ check(y, x, rnd, 0.0);
+ }
}
- }
#endif
check_inexact ();
check(948002822, 1.22191250737771397120e+20, GMP_RNDN,