summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2002-03-19 16:44:32 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2002-03-19 16:44:32 +0000
commit7f5910d6d74a6df6cdfe4e054daf146b2741eb8f (patch)
treeb599758d3a523f224d6f70c80befaf4a3733f31d
parent5e312be811d30870960160d99704344f5f6a6933 (diff)
downloadmpfr-7f5910d6d74a6df6cdfe4e054daf146b2741eb8f.tar.gz
now use macros DBL_NAN, DBL_POS_INF, DBL_NEG_INF,
and functions mpfr_set_nan, mpfr_set_inf git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@1758 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r--tests/reuse.c60
-rw-r--r--tests/tabs.c27
-rw-r--r--tests/tadd.c14
-rw-r--r--tests/tadd_ui.c20
-rw-r--r--tests/tcmp.c25
-rw-r--r--tests/tcos.c9
-rw-r--r--tests/tdiv.c15
-rw-r--r--tests/tmul.c10
-rw-r--r--tests/tmul_2exp.c10
-rw-r--r--tests/tmul_ui.c14
-rw-r--r--tests/tpow.c13
-rw-r--r--tests/tsin.c22
-rw-r--r--tests/tsin_cos.c19
-rw-r--r--tests/tsqrt.c9
-rw-r--r--tests/tsub_ui.c10
-rw-r--r--tests/ttan.c9
-rw-r--r--tests/tui_div.c9
-rw-r--r--tests/tui_sub.c9
18 files changed, 158 insertions, 146 deletions
diff --git a/tests/reuse.c b/tests/reuse.c
index 1a192fd4d..e93ad92bb 100644
--- a/tests/reuse.c
+++ b/tests/reuse.c
@@ -63,16 +63,16 @@ test3 (char *foo, mp_prec_t prec, mp_rnd_t rnd)
/* for each variable, consider each of the following 6 possibilities:
NaN, +Infinity, -Infinity, +0, -0 or a random number */
for (i=0; i<36; i++) {
- if (i%6==0) MPFR_SET_NAN(ref2);
- if (i%6==1) mpfr_set_d (ref2, 1.0/0.0, GMP_RNDN);
- if (i%6==2) mpfr_set_d (ref2, -1.0/0.0, GMP_RNDN);
+ if (i%6==0) mpfr_set_nan (ref2);
+ if (i%6==1) mpfr_set_inf (ref2, 1);
+ if (i%6==2) mpfr_set_inf (ref2, -1);
if (i%6==3) mpfr_set_d (ref2, 0.0, GMP_RNDN);
if (i%6==4) mpfr_set_d (ref2, -0.0, GMP_RNDN);
if (i%6==5) mpfr_random (ref2);
- if (i/6==0) MPFR_SET_NAN(ref3);
- if (i/6==1) mpfr_set_d (ref3, 1.0/0.0, GMP_RNDN);
- if (i/6==2) mpfr_set_d (ref3, -1.0/0.0, GMP_RNDN);
+ if (i/6==0) mpfr_set_nan (ref3);
+ if (i/6==1) mpfr_set_inf (ref3, 1);
+ if (i/6==2) mpfr_set_inf (ref3, -1);
if (i/6==3) mpfr_set_d (ref3, 0.0, GMP_RNDN);
if (i/6==4) mpfr_set_d (ref3, -0.0, GMP_RNDN);
if (i/6==5) mpfr_random (ref3);
@@ -147,9 +147,9 @@ test4 (char *foo, mp_prec_t prec, mp_rnd_t rnd)
{
MPFR_CLEAR_FLAGS(op1);
- if (i==0) MPFR_SET_NAN(op1);
- if (i==1) mpfr_set_d (op1, 1.0/0.0, GMP_RNDN);
- if (i==2) mpfr_set_d (op1, -1.0/0.0, GMP_RNDN);
+ if (i==0) mpfr_set_nan (op1);
+ if (i==1) mpfr_set_inf (op1, 1);
+ if (i==2) mpfr_set_inf (op1, -1);
if (i==3) mpfr_set_d (op1, 0.0, GMP_RNDN);
if (i==4) mpfr_set_d (op1, -0.0, GMP_RNDN);
if (i==5) mpfr_random (op1);
@@ -158,9 +158,9 @@ test4 (char *foo, mp_prec_t prec, mp_rnd_t rnd)
{
MPFR_CLEAR_FLAGS(op2);
- if (j==0) MPFR_SET_NAN(op2);
- if (j==1) mpfr_set_d (op2, 1.0/0.0, GMP_RNDN);
- if (j==2) mpfr_set_d (op2, -1.0/0.0, GMP_RNDN);
+ if (j==0) mpfr_set_nan (op2);
+ if (j==1) mpfr_set_inf (op2, 1);
+ if (j==2) mpfr_set_inf (op2, -1);
if (j==3) mpfr_set_d (op2, 0.0, GMP_RNDN);
if (j==4) mpfr_set_d (op2, -0.0, GMP_RNDN);
if (j==5) mpfr_random (op2);
@@ -169,9 +169,9 @@ test4 (char *foo, mp_prec_t prec, mp_rnd_t rnd)
{
MPFR_CLEAR_FLAGS(op3);
- if (k==0) MPFR_SET_NAN(op3);
- if (k==1) mpfr_set_d (op3, 1.0/0.0, GMP_RNDN);
- if (k==2) mpfr_set_d (op3, -1.0/0.0, GMP_RNDN);
+ if (k==0) mpfr_set_nan (op3);
+ if (k==1) mpfr_set_inf (op3, 1);
+ if (k==2) mpfr_set_inf (op3, -1);
if (k==3) mpfr_set_d (op3, 0.0, GMP_RNDN);
if (k==4) mpfr_set_d (op3, -0.0, GMP_RNDN);
if (k==5) mpfr_random (op3);
@@ -316,9 +316,9 @@ test2ui (char *foo, mp_prec_t prec, mp_rnd_t rnd)
ref3 can be 0 or any number */
for (i=0; i<12; i++)
{
- if (i%6==0) MPFR_SET_NAN(ref2);
- if (i%6==1) mpfr_set_d (ref2, 1.0/0.0, GMP_RNDN);
- if (i%6==2) mpfr_set_d (ref2, -1.0/0.0, GMP_RNDN);
+ if (i%6==0) mpfr_set_nan (ref2);
+ if (i%6==1) mpfr_set_inf (ref2, 1);
+ if (i%6==2) mpfr_set_inf (ref2, -1);
if (i%6==3) mpfr_set_d (ref2, 0.0, GMP_RNDN);
if (i%6==4) mpfr_set_d (ref2, -0.0, GMP_RNDN);
if (i%6==5) mpfr_random (ref2);
@@ -373,9 +373,9 @@ testui2 (char *foo, mp_prec_t prec, mp_rnd_t rnd)
ref2 = (unsigned int) c[0];
for (i=0; i<12; i++) {
- if (i%6==0) MPFR_SET_NAN(ref3);
- if (i%6==1) mpfr_set_d (ref3, 1.0/0.0, GMP_RNDN);
- if (i%6==2) mpfr_set_d (ref3, -1.0/0.0, GMP_RNDN);
+ if (i%6==0) mpfr_set_nan (ref3);
+ if (i%6==1) mpfr_set_inf (ref3, 1);
+ if (i%6==2) mpfr_set_inf (ref3, -1);
if (i%6==3) mpfr_set_d (ref3, 0.0, GMP_RNDN);
if (i%6==4) mpfr_set_d (ref3, -0.0, GMP_RNDN);
if (i%6==5) mpfr_random (ref3);
@@ -423,9 +423,9 @@ test2 (char *foo, mp_prec_t prec, mp_rnd_t rnd)
mpfr_random (ref2);
for (i=0; i<6; i++) {
- if (i==0) MPFR_SET_NAN(ref2);
- if (i==1) mpfr_set_d (ref2, 1.0/0.0, GMP_RNDN);
- if (i==2) mpfr_set_d (ref2, -1.0/0.0, GMP_RNDN);
+ if (i==0) mpfr_set_nan (ref2);
+ if (i==1) mpfr_set_inf (ref2, 1);
+ if (i==2) mpfr_set_inf (ref2, -1);
if (i==3) mpfr_set_d (ref2, 0.0, GMP_RNDN);
if (i==4) mpfr_set_d (ref2, -0.0, GMP_RNDN);
if (i==5) mpfr_random (ref2);
@@ -466,9 +466,9 @@ test2a (char *foo, mp_prec_t prec)
mpfr_random (ref2);
for (i=0; i<6; i++) {
- if (i==0) MPFR_SET_NAN(ref2);
- if (i==1) mpfr_set_d (ref2, 1.0/0.0, GMP_RNDN);
- if (i==2) mpfr_set_d (ref2, -1.0/0.0, GMP_RNDN);
+ if (i==0) mpfr_set_nan (ref2);
+ if (i==1) mpfr_set_inf (ref2, 1);
+ if (i==2) mpfr_set_inf (ref2, -1);
if (i==3) mpfr_set_d (ref2, 0.0, GMP_RNDN);
if (i==4) mpfr_set_d (ref2, -0.0, GMP_RNDN);
if (i==5) mpfr_random (ref2);
@@ -511,9 +511,9 @@ test3a (char *foo, mp_prec_t prec, mp_rnd_t rnd)
mpfr_random (ref3);
for (i=0; i<6; i++) {
- if (i==0) MPFR_SET_NAN(ref3);
- if (i==1) mpfr_set_d (ref3, 1.0/0.0, GMP_RNDN);
- if (i==2) mpfr_set_d (ref3, -1.0/0.0, GMP_RNDN);
+ if (i==0) mpfr_set_nan (ref3);
+ if (i==1) mpfr_set_inf (ref3, 1);
+ if (i==2) mpfr_set_inf (ref3, -1);
if (i==3) mpfr_set_d (ref3, 0.0, GMP_RNDN);
if (i==4) mpfr_set_d (ref3, -0.0, GMP_RNDN);
if (i==5) mpfr_random (ref3);
diff --git a/tests/tabs.c b/tests/tabs.c
index bf5964d1e..736c2335f 100644
--- a/tests/tabs.c
+++ b/tests/tabs.c
@@ -25,8 +25,6 @@ MA 02111-1307, USA. */
#include "mpfr.h"
#include "mpfr-test.h"
-#define Infp (1/0.)
-
void check_inexact _PROTO((void));
void
@@ -107,18 +105,21 @@ main (int argc, char *argv[])
fprintf(stderr, "Error in mpfr_abs(-1.0)\n"); exit(1);
}
- mpfr_set_d(x, -6/-0., GMP_RNDN);
- mpfr_abs(x, x, GMP_RNDN);
- if (mpfr_get_d(x) != Infp) {
- fprintf(stderr, "Error in mpfr_abs(Inf).\n"); exit(1);
- }
-
- mpfr_set_d(x, 2/-0., GMP_RNDN);
- mpfr_abs(x, x, GMP_RNDN);
- if (mpfr_get_d(x) != Infp) {
- fprintf(stderr, "Error in mpfr_abs(-Inf).\n"); exit(1);
- }
+ mpfr_set_d (x, -6/-0., GMP_RNDN);
+ mpfr_abs (x, x, GMP_RNDN);
+ if (!mpfr_inf_p(x) || (mpfr_sgn(x) <= 0))
+ {
+ fprintf (stderr, "Error in mpfr_abs(Inf).\n");
+ exit (1);
+ }
+ mpfr_set_d (x, 2/-0., GMP_RNDN);
+ mpfr_abs (x, x, GMP_RNDN);
+ if (!mpfr_inf_p(x) || (mpfr_sgn(x) <= 0))
+ {
+ fprintf (stderr, "Error in mpfr_abs(-Inf).\n");
+ exit (1);
+ }
n = (argc==1) ? 1000000 : atoi(argv[1]);
for (k = 1; k <= n; k++)
diff --git a/tests/tadd.c b/tests/tadd.c
index cb8a34b03..69bbed11a 100644
--- a/tests/tadd.c
+++ b/tests/tadd.c
@@ -435,7 +435,7 @@ check64 (void)
/* checks that NaN flag is correctly reset */
mpfr_set_d (t, 1.0, GMP_RNDN);
mpfr_set_d (u, 1.0, GMP_RNDN);
- MPFR_SET_NAN(x);
+ mpfr_set_nan (x);
mpfr_add (x, t, u, GMP_RNDN);
if (mpfr_cmp_ui (x, 2)) {
fprintf (stderr, "Error in mpfr_add: 1+1 gives %e\n", mpfr_get_d (x));
@@ -792,7 +792,7 @@ main (int argc, char *argv[])
1.4245325800982785854e240);
/* the following check double overflow */
check53(6.27557402141211962228e+307, 1.32141396570101687757e+308,
- GMP_RNDZ, 1.0/0.0);
+ GMP_RNDZ, DBL_POS_INF);
check53(1.00944884131046636376e+221, 2.33809162651471520268e+215, GMP_RNDN,
1.0094511794020929787e221);
check53(4.29232078932667367325e-278, 1.07735250473897938332e-281, GMP_RNDU,
@@ -817,14 +817,14 @@ main (int argc, char *argv[])
/* test denormalized numbers too */
check53(8.06294740693074521573e-310, 6.95250701071929654575e-310, GMP_RNDU,
1.5015454417650041761e-309);
- check53(1/0., 6.95250701071929654575e-310, GMP_RNDU, 1/0.);
- check53(-1/0., 6.95250701071929654575e-310, GMP_RNDU, -1/0.);
- check53(6.95250701071929654575e-310, 1/0., GMP_RNDU, 1/0.);
- check53(6.95250701071929654575e-310, -1/0., GMP_RNDU, -1/0.);
+ check53(DBL_POS_INF, 6.95250701071929654575e-310, GMP_RNDU, DBL_POS_INF);
+ check53(DBL_NEG_INF, 6.95250701071929654575e-310, GMP_RNDU, DBL_NEG_INF);
+ check53(6.95250701071929654575e-310, DBL_POS_INF, GMP_RNDU, DBL_POS_INF);
+ check53(6.95250701071929654575e-310, DBL_NEG_INF, GMP_RNDU, DBL_NEG_INF);
check53(1.44791789689198883921e-140, -1.90982880222349071284e-121,
GMP_RNDN, -1.90982880222349071e-121);
- check53nan(1/0., -1/0., GMP_RNDN);
+ check53nan (DBL_POS_INF, DBL_NEG_INF, GMP_RNDN);
/* tests for particular cases (Vincent Lefevre, 22 Aug 2001) */
check53(9007199254740992.0, 1.0, GMP_RNDN, 9007199254740992.0);
diff --git a/tests/tadd_ui.c b/tests/tadd_ui.c
index d0df80981..778062ad2 100644
--- a/tests/tadd_ui.c
+++ b/tests/tadd_ui.c
@@ -104,15 +104,17 @@ main (int argc, char *argv[])
}
#endif
special ();
- check3(-1.716113812768534e-140, 1271212614, GMP_RNDZ, 1.27121261399999976e9);
- check3(1.22191250737771397120e+20, 948002822, GMP_RNDN,
- 122191250738719408128.0);
- check3(-6.72658901114033715233e-165, 2000878121, GMP_RNDZ,
- 2.0008781209999997615e9);
- check3(-2.0769715792901673e-5, 880524, GMP_RNDN, 8.8052399997923023e5);
- check3(1/0., 2394875, GMP_RNDN, 1/0.);
- check3(-1/0., 2394875, GMP_RNDN, -1/0.);
- check3(0./0., 2394875, GMP_RNDN, 0./0.);
+ check3 (-1.716113812768534e-140, 1271212614, GMP_RNDZ,
+ 1.27121261399999976e9);
+ check3 (1.22191250737771397120e+20, 948002822, GMP_RNDN,
+ 122191250738719408128.0);
+ check3 (-6.72658901114033715233e-165, 2000878121, GMP_RNDZ,
+ 2.0008781209999997615e9);
+ check3 (-2.0769715792901673e-5, 880524, GMP_RNDN, 8.8052399997923023e5);
+ check3 (DBL_POS_INF, 2394875, GMP_RNDN, DBL_POS_INF);
+ check3 (DBL_NEG_INF, 2394875, GMP_RNDN, DBL_NEG_INF);
+ check3 (DBL_NAN, 2394875, GMP_RNDN, DBL_NAN);
+
return 0;
}
diff --git a/tests/tcmp.c b/tests/tcmp.c
index 637cfa517..3db356ae4 100644
--- a/tests/tcmp.c
+++ b/tests/tcmp.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_cmp.
-Copyright 1999, 2001 Free Software Foundation, Inc.
+Copyright 1999, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -27,9 +27,6 @@ MA 02111-1307, USA. */
#include "mpfr-impl.h"
#include "mpfr-test.h"
-#define Infp 1/0.
-#define Infm -1/0.
-
int
main (void)
{
@@ -103,7 +100,7 @@ main (void)
exit(1);
}
- mpfr_set_d(xx, Infp, GMP_RNDN);
+ mpfr_set_inf (xx, 1);
mpfr_set_d(yy, -23489745.0329, GMP_RNDN);
if (mpfr_cmp(xx, yy) <= 0) {
fprintf(stderr,
@@ -111,39 +108,39 @@ main (void)
exit(1);
}
- mpfr_set_d(xx, Infp, GMP_RNDN);
- mpfr_set_d(yy, Infm, GMP_RNDN);
+ mpfr_set_inf (xx, 1);
+ mpfr_set_inf (yy, -1);
if (mpfr_cmp(xx, yy) <= 0) {
fprintf(stderr,
"Error in mpfr_cmp(Infp, Infm), gives %d\n", mpfr_cmp(xx, yy));
exit(1);
}
- mpfr_set_d(xx, Infm, GMP_RNDN);
- mpfr_set_d(yy, Infp, GMP_RNDN);
+ mpfr_set_inf (xx, -1);
+ mpfr_set_inf (yy, 1);
if (mpfr_cmp(xx, yy) >= 0) {
fprintf(stderr,
"Error in mpfr_cmp(Infm, Infp), gives %d\n", mpfr_cmp(xx, yy));
exit(1);
}
- mpfr_set_d(xx, Infp, GMP_RNDN);
- mpfr_set_d(yy, Infp, GMP_RNDN);
+ mpfr_set_inf (xx, 1);
+ mpfr_set_inf (yy, 1);
if (mpfr_cmp(xx, yy) != 0) {
fprintf(stderr,
"Error in mpfr_cmp(Infp, Infp), gives %d\n", mpfr_cmp(xx, yy));
exit(1);
}
- mpfr_set_d(xx, Infm, GMP_RNDN);
- mpfr_set_d(yy, Infm, GMP_RNDN);
+ mpfr_set_inf (xx, -1);
+ mpfr_set_inf (yy, -1);
if (mpfr_cmp(xx, yy) != 0) {
fprintf(stderr,
"Error in mpfr_cmp(Infm, Infm), gives %d\n", mpfr_cmp(xx, yy));
exit(1);
}
- mpfr_set_d(xx, Infm, GMP_RNDN);
+ mpfr_set_inf (xx, -1);
mpfr_set_d(yy, 2346.09234, GMP_RNDN);
if (mpfr_cmp(xx, yy) >= 0) {
fprintf(stderr,
diff --git a/tests/tcos.c b/tests/tcos.c
index f4dd43290..a32811e2e 100644
--- a/tests/tcos.c
+++ b/tests/tcos.c
@@ -24,6 +24,7 @@ MA 02111-1307, USA. */
#include <math.h>
#include "gmp.h"
#include "mpfr.h"
+#include "mpfr-impl.h"
#include "mpfr-test.h"
void check53 _PROTO ((double, double, mp_rnd_t));
@@ -37,7 +38,7 @@ check53 (double x, double cos_x, mp_rnd_t rnd_mode)
mpfr_init2 (c, 53);
mpfr_set_d (xx, x, rnd_mode); /* should be exact */
mpfr_cos (c, xx, rnd_mode);
- if (mpfr_get_d (c) != cos_x && (!isnan(cos_x) || !isnan(mpfr_get_d(c))))
+ if (mpfr_get_d (c) != cos_x && (!isnan(cos_x) || !mpfr_nan_p(c)))
{
fprintf (stderr, "mpfr_cos failed for x=%1.20e, rnd=%s\n", x,
mpfr_print_rnd_mode (rnd_mode));
@@ -103,9 +104,9 @@ main (int argc, char *argv[])
exit (1);
}
- check53(0.0/0.0, 0.0/0.0, GMP_RNDN);
- check53(1.0/0.0, 0.0/0.0, GMP_RNDN);
- check53(-1.0/0.0, 0.0/0.0, GMP_RNDN);
+ check53 (DBL_NAN, DBL_NAN, GMP_RNDN);
+ check53 (DBL_POS_INF, DBL_NAN, GMP_RNDN);
+ check53 (DBL_NEG_INF, DBL_NAN, GMP_RNDN);
/* worst case from PhD thesis of Vincent Lefe`vre: x=8980155785351021/2^54 */
check53 (4.984987858808754279e-1, 8.783012931285841817e-1, GMP_RNDN);
diff --git a/tests/tdiv.c b/tests/tdiv.c
index ba49ac13e..2ac52587d 100644
--- a/tests/tdiv.c
+++ b/tests/tdiv.c
@@ -24,10 +24,9 @@ MA 02111-1307, USA. */
#include <unistd.h>
#include "gmp.h"
#include "mpfr.h"
+#include "mpfr-impl.h"
#include "mpfr-test.h"
-#define NaN (0./0.)
-
#define check53(n, d, rnd, res) check4(n, d, rnd, 53, res)
void check4 _PROTO((double, double, mp_rnd_t, int, double));
@@ -425,12 +424,12 @@ main (int argc, char *argv[])
65, 0.0);
check53(9.89438396044940256501e-134, 5.93472984109987421717e-67, GMP_RNDU,
1.6672003992376663654e-67);
- check53(1.0, NaN, GMP_RNDD, NaN);
- check53(NaN, 1.0, GMP_RNDD, NaN);
- check53(2.0/0.0, 1.0, GMP_RNDD, 1.0/0.0);
- check53(1.0, 2.0/0.0, GMP_RNDD, 0.0);
- check53(0.0, 0.0, GMP_RNDD, NaN);
- check53(1.0/0.0, 1.0/0.0, GMP_RNDD, NaN);
+ check53 (1.0, DBL_NAN, GMP_RNDD, DBL_NAN);
+ check53 (DBL_NAN, 1.0, GMP_RNDD, DBL_NAN);
+ check53 (DBL_POS_INF, 1.0, GMP_RNDD, DBL_POS_INF);
+ check53 (1.0, DBL_POS_INF, GMP_RNDD, 0.0);
+ check53 (0.0, 0.0, GMP_RNDD, DBL_NAN);
+ check53 (DBL_POS_INF, DBL_POS_INF, GMP_RNDD, DBL_NAN);
check53(9.89438396044940256501e-134, -5.93472984109987421717e-67, GMP_RNDU,
-1.6672003992376663654e-67);
check53(-4.53063926135729747564e-308, 7.02293374921793516813e-84, GMP_RNDD,
diff --git a/tests/tmul.c b/tests/tmul.c
index 77cad2910..9b4fc8b69 100644
--- a/tests/tmul.c
+++ b/tests/tmul.c
@@ -347,11 +347,11 @@ main (int argc, char *argv[])
check_exact ();
check_float ();
- check53(0.0, 1.0/0.0, GMP_RNDN, 0.0/0.0);
- check53(1.0, 1.0/0.0, GMP_RNDN, 1.0/0.0);
- check53(-1.0, 1.0/0.0, GMP_RNDN, -1.0/0.0);
- check53(0.0/0.0, 0.0, GMP_RNDN, 0.0/0.0);
- check53(1.0, 0.0/0.0, GMP_RNDN, 0.0/0.0);
+ check53 (0.0, DBL_POS_INF, GMP_RNDN, DBL_NAN);
+ check53(1.0, DBL_POS_INF, GMP_RNDN, DBL_POS_INF);
+ check53(-1.0, DBL_POS_INF, GMP_RNDN, DBL_NEG_INF);
+ check53(DBL_NAN, 0.0, GMP_RNDN, DBL_NAN);
+ check53(1.0, DBL_NAN, GMP_RNDN, DBL_NAN);
check53(6.9314718055994530941514e-1, 0.0, GMP_RNDZ, 0.0);
check53(0.0, 6.9314718055994530941514e-1, GMP_RNDZ, 0.0);
check_sign();
diff --git a/tests/tmul_2exp.c b/tests/tmul_2exp.c
index 5b9182725..73cf61696 100644
--- a/tests/tmul_2exp.c
+++ b/tests/tmul_2exp.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_mul_2exp.
-Copyright 1999, 2001 Free Software Foundation.
+Copyright 1999, 2001, 2002 Free Software Foundation.
This file is part of the MPFR Library.
@@ -36,12 +36,12 @@ main (int argc, char *argv[])
mpfr_init2(w, 53);
- mpfr_set_d(w, 1.0/0.0, 0);
- mpfr_mul_2exp(w, w, 10, GMP_RNDZ);
+ mpfr_set_inf (w, 1);
+ mpfr_mul_2exp (w, w, 10, GMP_RNDZ);
if (!MPFR_IS_INF(w)) { fprintf(stderr, "Inf != Inf"); exit(-1); }
- mpfr_set_d(w, 0.0/0.0, 0);
- mpfr_mul_2exp(w, w, 10, GMP_RNDZ);
+ mpfr_set_nan (w);
+ mpfr_mul_2exp (w, w, 10, GMP_RNDZ);
if (!MPFR_IS_NAN(w)) { fprintf(stderr, "NaN != NaN"); exit(-1); }
for (k = 0; k < 100000; k++) {
diff --git a/tests/tmul_ui.c b/tests/tmul_ui.c
index 9ff639fb6..f07620cc9 100644
--- a/tests/tmul_ui.c
+++ b/tests/tmul_ui.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_mul_ui.
-Copyright 1999, 2000, 2001 Free Software Foundation.
+Copyright 1999, 2000, 2001, 2002 Free Software Foundation.
This file is part of the MPFR Library.
@@ -109,25 +109,25 @@ main (int argc, char *argv[])
}
- mpfr_set_d (x, 1.0/0.0, GMP_RNDZ);
+ mpfr_set_inf (x, 1);
mpfr_mul_ui (x, x, 3, GMP_RNDU);
- if (mpfr_get_d (x) != 1.0/0.0)
+ if (mpfr_get_d (x) != DBL_POS_INF)
{
fprintf (stderr, "Error in mpfr_mul_ui: Inf*3 does not give Inf\n");
exit (1);
}
- mpfr_set_d (x, -1.0/0.0, GMP_RNDZ);
+ mpfr_set_inf (x, -1);
mpfr_mul_ui (x, x, 3, GMP_RNDU);
- if (mpfr_get_d (x) != -1.0/0.0)
+ if (mpfr_get_d (x) != DBL_NEG_INF)
{
fprintf (stderr, "Error in mpfr_mul_ui: -Inf*3 does not give -Inf\n");
exit (1);
}
- mpfr_set_d (x, 0.0/0.0, GMP_RNDZ);
+ mpfr_set_nan (x);
mpfr_mul_ui (x, x, 3, GMP_RNDU);
- if (!isnan(mpfr_get_d(x)))
+ if (!mpfr_nan_p(x))
{
fprintf (stderr, "Error in mpfr_mul_ui: NaN*3 does not give NaN\n");
exit (1);
diff --git a/tests/tpow.c b/tests/tpow.c
index 882f874dd..a023bb956 100644
--- a/tests/tpow.c
+++ b/tests/tpow.c
@@ -23,6 +23,7 @@ MA 02111-1307, USA. */
#include <stdlib.h>
#include "gmp.h"
#include "mpfr.h"
+#include "mpfr-impl.h"
void check_pow_ui _PROTO ((void));
void check_inexact _PROTO ((mp_prec_t));
@@ -45,17 +46,17 @@ check_pow_ui (void)
/* check large exponents */
mpfr_set_d (b, 1, GMP_RNDN);
- mpfr_pow_ui (a, b, (unsigned long) 4294967295, GMP_RNDN);
+ mpfr_pow_ui (a, b, 4294967295UL, GMP_RNDN);
- mpfr_set_d (a, -1.0/0.0, GMP_RNDN);
- mpfr_pow_ui (a, a, (unsigned long) 4049053855, GMP_RNDN);
- if (mpfr_get_d (a) != -1.0/0.0) {
+ mpfr_set_inf (a, -1);
+ mpfr_pow_ui (a, a, 4049053855UL, GMP_RNDN);
+ if (mpfr_get_d (a) != DBL_NEG_INF) {
fprintf (stderr, "Error for (-Inf)^4049053855\n"); exit (1);
}
- mpfr_set_d (a, -1.0/0.0, GMP_RNDN);
+ mpfr_set_inf (a, -1);
mpfr_pow_ui (a, a, (unsigned long) 30002752, GMP_RNDN);
- if (mpfr_get_d (a) != 1.0/0.0) {
+ if (mpfr_get_d (a) != DBL_POS_INF) {
fprintf (stderr, "Error for (-Inf)^30002752\n"); exit (1);
}
diff --git a/tests/tsin.c b/tests/tsin.c
index 6c085bdc0..a5a074f0e 100644
--- a/tests/tsin.c
+++ b/tests/tsin.c
@@ -24,6 +24,7 @@ MA 02111-1307, USA. */
#include <math.h>
#include "gmp.h"
#include "mpfr.h"
+#include "mpfr-impl.h"
#include "mpfr-test.h"
void check53 _PROTO ((double, double, mp_rnd_t));
@@ -37,13 +38,14 @@ check53 (double x, double sin_x, mp_rnd_t rnd_mode)
mpfr_init2 (s, 53);
mpfr_set_d (xx, x, rnd_mode); /* should be exact */
mpfr_sin (s, xx, rnd_mode);
- if (mpfr_get_d (s) != sin_x && (!isnan(sin_x) || !isnan(mpfr_get_d(s)))) {
- fprintf (stderr, "mpfr_sin failed for x=%1.20e, rnd=%s\n", x,
- mpfr_print_rnd_mode (rnd_mode));
- fprintf (stderr, "mpfr_sin gives sin(x)=%1.20e, expected %1.20e\n",
- mpfr_get_d (s), sin_x);
- exit(1);
- }
+ if (mpfr_get_d (s) != sin_x && (!isnan(sin_x) || !mpfr_nan_p(s)))
+ {
+ fprintf (stderr, "mpfr_sin failed for x=%1.20e, rnd=%s\n", x,
+ mpfr_print_rnd_mode (rnd_mode));
+ fprintf (stderr, "mpfr_sin gives sin(x)=%1.20e, expected %1.20e\n",
+ mpfr_get_d (s), sin_x);
+ exit(1);
+ }
mpfr_clear (xx);
mpfr_clear (s);
}
@@ -56,9 +58,9 @@ main (int argc, char *argv[])
{
mpfr_t x;
- check53(0.0/0.0, 0.0/0.0, GMP_RNDN);
- check53(1.0/0.0, 0.0/0.0, GMP_RNDN);
- check53(-1.0/0.0, 0.0/0.0, GMP_RNDN);
+ check53 (DBL_NAN, DBL_NAN, GMP_RNDN);
+ check53 (DBL_POS_INF, DBL_NAN, GMP_RNDN);
+ check53 (DBL_NEG_INF, DBL_NAN, GMP_RNDN);
/* worst case from PhD thesis of Vincent Lefe`vre: x=8980155785351021/2^54 */
check53 (4.984987858808754279e-1, 4.781075595393330379e-1, GMP_RNDN);
check53 (4.984987858808754279e-1, 4.781075595393329824e-1, GMP_RNDD);
diff --git a/tests/tsin_cos.c b/tests/tsin_cos.c
index 98772ca00..cdc5d9f1f 100644
--- a/tests/tsin_cos.c
+++ b/tests/tsin_cos.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_sin_cos.
-Copyright 2000, 2001 Free Software Foundation, Inc.
+Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -19,6 +19,9 @@ along with the MPFR Library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
#include "gmp.h"
#include "mpfr.h"
@@ -53,14 +56,14 @@ void check53 (double x, double sin_x, double cos_x, mp_rnd_t rnd_mode)
mpfr_init2 (c, 53);
mpfr_set_d (xx, x, rnd_mode); /* should be exact */
mpfr_sin_cos (s, c, xx, rnd_mode);
- if (mpfr_get_d (s) != sin_x && (!isnan(sin_x) || !isnan(mpfr_get_d(s)))) {
+ if (mpfr_get_d (s) != sin_x && (!isnan(sin_x) || !mpfr_nan_p(s))) {
fprintf (stderr, "mpfr_sin_cos failed for x=%1.20e, rnd=%s\n", x,
mpfr_print_rnd_mode (rnd_mode));
fprintf (stderr, "mpfr_sin_cos gives sin(x)=%1.20e, expected %1.20e\n",
mpfr_get_d (s), sin_x);
exit(1);
}
- if (mpfr_get_d (c) != cos_x && (!isnan(cos_x) || !isnan(mpfr_get_d(c)))) {
+ if (mpfr_get_d (c) != cos_x && (!isnan(cos_x) || !mpfr_nan_p(c))) {
fprintf (stderr, "mpfr_sin_cos failed for x=%1.20e, rnd=%s\n", x,
mpfr_print_rnd_mode (rnd_mode));
fprintf (stderr, "mpfr_sin_cos gives cos(x)=%1.20e, expected %1.20e\n",
@@ -80,7 +83,7 @@ void check53sin (double x, double sin_x, mp_rnd_t rnd_mode)
mpfr_init2 (s, 53);
mpfr_set_d (xx, x, rnd_mode); /* should be exact */
mpfr_sin_cos (s, NULL, xx, rnd_mode);
- if (mpfr_get_d (s) != sin_x && (!isnan(sin_x) || !isnan(mpfr_get_d(s)))) {
+ if (mpfr_get_d (s) != sin_x && (!isnan(sin_x) || !mpfr_nan_p(s))) {
fprintf (stderr, "mpfr_sin_cos failed for x=%1.20e, rnd=%s\n", x,
mpfr_print_rnd_mode (rnd_mode));
fprintf (stderr, "mpfr_sin_cos gives sin(x)=%1.20e, expected %1.20e\n",
@@ -99,7 +102,7 @@ void check53cos (double x, double cos_x, mp_rnd_t rnd_mode)
mpfr_init2 (c, 53);
mpfr_set_d (xx, x, rnd_mode); /* should be exact */
mpfr_sin_cos (NULL, c, xx, rnd_mode);
- if (mpfr_get_d (c) != cos_x && (!isnan(cos_x) || !isnan(mpfr_get_d(c)))) {
+ if (mpfr_get_d (c) != cos_x && (!isnan(cos_x) || !mpfr_nan_p(c))) {
fprintf (stderr, "mpfr_sin_cos failed for x=%1.20e, rnd=%s\n", x,
mpfr_print_rnd_mode (rnd_mode));
fprintf (stderr, "mpfr_sin_cos gives cos(x)=%1.20e, expected %1.20e\n",
@@ -118,9 +121,9 @@ main(int argc, char *argv[])
large_test (atoi (argv[1]), (argc > 2) ? atoi (argv[2]) : 1);
}
- check53(0.0/0.0, 0.0/0.0, 0.0/0.0, GMP_RNDN);
- check53(1.0/0.0, 0.0/0.0, 0.0/0.0, GMP_RNDN);
- check53(-1.0/0.0, 0.0/0.0, 0.0/0.0, GMP_RNDN);
+ check53 (DBL_NAN, DBL_NAN, DBL_NAN, GMP_RNDN);
+ check53 (DBL_POS_INF, DBL_NAN, DBL_NAN, GMP_RNDN);
+ check53 (DBL_NEG_INF, DBL_NAN, DBL_NAN, GMP_RNDN);
/* worst case from PhD thesis of Vincent Lefe`vre: x=8980155785351021/2^54 */
check53 (4.984987858808754279e-1, 4.781075595393330379e-1,
8.783012931285841817e-1, GMP_RNDN);
diff --git a/tests/tsqrt.c b/tests/tsqrt.c
index 7dbf45481..7420ca556 100644
--- a/tests/tsqrt.c
+++ b/tests/tsqrt.c
@@ -24,6 +24,7 @@ MA 02111-1307, USA. */
#include <stdlib.h>
#include "gmp.h"
#include "mpfr.h"
+#include "mpfr-impl.h"
#include "mpfr-test.h"
#define check(a,r) check3(a,r,-1.0)
@@ -300,10 +301,10 @@ main (void)
check_inexact (p);
special ();
check_float();
- check3(0.0/0.0, GMP_RNDN, 0.0/0.0);
- check3(-1.0, GMP_RNDN, 0.0/0.0);
- check3(1.0/0.0, GMP_RNDN, 1.0/0.0);
- check3(-1.0/0.0, GMP_RNDN, 0.0/0.0);
+ check3 (DBL_NAN, GMP_RNDN, DBL_NAN);
+ check3 (-1.0, GMP_RNDN, DBL_NAN);
+ check3 (DBL_POS_INF, GMP_RNDN, DBL_POS_INF);
+ check3 (DBL_NEG_INF, GMP_RNDN, DBL_NAN);
check3(-0.0, GMP_RNDN, 0.0);
check4(6.37983013646045901440e+32, GMP_RNDN, "5.9bc5036d09e0c@13");
check4(1.0, GMP_RNDN, "1");
diff --git a/tests/tsub_ui.c b/tests/tsub_ui.c
index 3f7dd7e8c..3e18ae101 100644
--- a/tests/tsub_ui.c
+++ b/tests/tsub_ui.c
@@ -144,10 +144,12 @@ main (int argc, char *argv[])
for (p=2; p<200; p++)
for (k=0; k<200; k++)
check_two_sum (p);
- check3(0.9999999999, 1, GMP_RNDN, -1.000000082740370999e-10);
- check3(0.0/0.0, 1, GMP_RNDN, 0.0/0.0);
- check3(1.0/0.0, 1, GMP_RNDN, 1.0/0.0);
- check3(-1.0/0.0, 1, GMP_RNDN, -1.0/0.0);
+
+ check3 (0.9999999999, 1, GMP_RNDN, -1.000000082740370999e-10);
+ check3 (DBL_NAN, 1, GMP_RNDN, DBL_NAN);
+ check3 (DBL_POS_INF, 1, GMP_RNDN, DBL_POS_INF);
+ check3 (DBL_NEG_INF, 1, GMP_RNDN, DBL_NEG_INF);
+
return 0;
}
diff --git a/tests/ttan.c b/tests/ttan.c
index b14683dd0..714ee104f 100644
--- a/tests/ttan.c
+++ b/tests/ttan.c
@@ -24,6 +24,7 @@ MA 02111-1307, USA. */
#include <math.h>
#include "gmp.h"
#include "mpfr.h"
+#include "mpfr-impl.h"
#include "mpfr-test.h"
void check53 _PROTO ((double, double, mp_rnd_t));
@@ -37,7 +38,7 @@ check53 (double x, double tan_x, mp_rnd_t rnd_mode)
mpfr_init2 (s, 53);
mpfr_set_d (xx, x, rnd_mode); /* should be exact */
mpfr_tan (s, xx, rnd_mode);
- if (mpfr_get_d (s) != tan_x && (!isnan(tan_x) || !isnan(mpfr_get_d(s)))) {
+ if (mpfr_get_d (s) != tan_x && (!isnan(tan_x) || !mpfr_nan_p(s))) {
fprintf (stderr, "mpfr_tan failed for x=%1.20e, rnd=%s\n", x,
mpfr_print_rnd_mode (rnd_mode));
fprintf (stderr, "mpfr_tan gives tan(x)=%1.20e, expected %1.20e\n",
@@ -59,9 +60,9 @@ main(int argc, char *argv[])
unsigned int prec[10] = {14, 15, 19, 22, 23, 24, 25, 40, 41, 52};
unsigned int prec2[10] = {4, 5, 6, 19, 70, 95, 100, 106, 107, 108};
- check53(0.0/0.0, 0.0/0.0, GMP_RNDN);
- check53(1.0/0.0, 0.0/0.0, GMP_RNDN);
- check53(-1.0/0.0, 0.0/0.0, GMP_RNDN);
+ check53 (DBL_NAN, DBL_NAN, GMP_RNDN);
+ check53 (DBL_POS_INF, DBL_NAN, GMP_RNDN);
+ check53 (DBL_NEG_INF, DBL_NAN, GMP_RNDN);
mpfr_init (x);
diff --git a/tests/tui_div.c b/tests/tui_div.c
index 3f749cf34..54e557e88 100644
--- a/tests/tui_div.c
+++ b/tests/tui_div.c
@@ -24,6 +24,7 @@ MA 02111-1307, USA. */
#include <stdlib.h>
#include "gmp.h"
#include "mpfr.h"
+#include "mpfr-impl.h"
#include "mpfr-test.h"
void check _PROTO((unsigned long, double, mp_rnd_t, double));
@@ -134,10 +135,10 @@ main (int argc, char *argv[])
}
#endif
check_inexact ();
- check(1, 1.0/0.0, GMP_RNDN, 0.0);
- check(1, -1.0/0.0, GMP_RNDN, -0.0);
- check(1, 0.0/0.0, GMP_RNDN, 0.0/0.0);
- check(0, 0.0, GMP_RNDN, 0.0/0.0);
+ check (1, DBL_POS_INF, GMP_RNDN, 0.0);
+ check(1, DBL_NEG_INF, GMP_RNDN, -0.0);
+ check(1, DBL_NAN, GMP_RNDN, DBL_NAN);
+ check(0, 0.0, GMP_RNDN, DBL_NAN);
check(948002822, 1.22191250737771397120e+20, GMP_RNDN,
7.758352715731357946e-12);
check(1976245324, 1.25296395864546893357e+232, GMP_RNDZ,
diff --git a/tests/tui_sub.c b/tests/tui_sub.c
index 2cf26a8f3..89b9bba6f 100644
--- a/tests/tui_sub.c
+++ b/tests/tui_sub.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_ui_sub.
-Copyright 2000, 2001 Free Software Foundation.
+Copyright 2000, 2001, 2002 Free Software Foundation.
This file is part of the MPFR Library.
@@ -24,6 +24,7 @@ MA 02111-1307, USA. */
#include <stdlib.h>
#include "gmp.h"
#include "mpfr.h"
+#include "mpfr-impl.h"
#include "mpfr-test.h"
void special _PROTO ((void));
@@ -231,9 +232,9 @@ main (int argc, char *argv[])
for (p=2; p<100; p++)
for (k=0; k<100; k++)
check_two_sum (p);
- check(1, 1.0/0.0, GMP_RNDN, -1.0/0.0);
- check(1, -1.0/0.0, GMP_RNDN, 1.0/0.0);
- check(1, 0.0/0.0, GMP_RNDN, 0.0/0.0);
+ check (1, DBL_POS_INF, GMP_RNDN, DBL_NEG_INF);
+ check (1, DBL_NEG_INF, GMP_RNDN, DBL_POS_INF);
+ check (1, DBL_NAN, GMP_RNDN, DBL_NAN);
check(1196426492, 1.4218093058435347e-3, GMP_RNDN, 1.1964264919985781e9);
check(1092583421, -1.0880649218158844e9, GMP_RNDN, 2.1806483428158845901e9);
check(948002822, 1.22191250737771397120e+20, GMP_RNDN,