summaryrefslogtreecommitdiff
path: root/tests/tcmp2.c
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2003-01-17 08:58:45 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2003-01-17 08:58:45 +0000
commit7b809d142e26babd6be428c770ca38fd8d3235a5 (patch)
tree6d9688c7d7a1ee63ef433b8cf66f1f118c8ef808 /tests/tcmp2.c
parent35d33676c4a43b10fcee59a3ea7b9ee807a63415 (diff)
downloadmpfr-7b809d142e26babd6be428c770ca38fd8d3235a5.tar.gz
now use __gmpfr_floor_log2 instead of floor/log to get rid of math.h
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2199 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests/tcmp2.c')
-rw-r--r--tests/tcmp2.c55
1 files changed, 34 insertions, 21 deletions
diff --git a/tests/tcmp2.c b/tests/tcmp2.c
index 0de90b5f8..b290c9b92 100644
--- a/tests/tcmp2.c
+++ b/tests/tcmp2.c
@@ -19,7 +19,6 @@ 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 <math.h> /* for log and floor in tcmp2() */
#include <stdio.h>
#include <stdlib.h>
#include "gmp.h"
@@ -153,9 +152,12 @@ tcmp2 (double x, double y, int i)
mpfr_t xx, yy;
mp_prec_t j;
- if (i==-1) {
- if (x==y) i=53;
- else i = (int) floor(log(x)/log(2.0)) - (int) floor(log(x-y)/log(2.0));
+ if (i == -1)
+ {
+ if (x == y)
+ i = 53;
+ else
+ i = (int) (__gmpfr_floor_log2 (x) - __gmpfr_floor_log2 (x - y));
}
mpfr_init2(xx, 53); mpfr_init2(yy, 53);
mpfr_set_d (xx, x, GMP_RNDN);
@@ -279,31 +281,42 @@ special (void)
int
main (void)
{
- int i,j; double x=1.0, y, z;
+ int i, j;
+ double x = 1.0, y, z;
tests_start_mpfr ();
mpfr_test_init ();
worst_cases ();
special ();
- tcmp2(5.43885304644369510000e+185, -1.87427265794105340000e-57, 1);
- tcmp2(1.06022698059744327881e+71, 1.05824655795525779205e+71, -1);
- tcmp2(1.0, 1.0, 53);
- for (i=0;i<54;i++) {
- tcmp2 (1.0, 1.0-x, i);
- x /= 2.0;
- }
- for (x=0.5, i=1; i<100; i++) {
- tcmp2 (1.0, x, 1);
- x /= 2.0;
- }
- for (j=0; j<100000; j++) {
- x = DBL_RAND ();
- y = DBL_RAND ();
- if (x<y) { z=x; x=y; y=z; }
- if (y != 0.0 && y != -0.0) tcmp2(x, y, -1);
+ tcmp2 (5.43885304644369510000e+185, -1.87427265794105340000e-57, 1);
+ tcmp2 (1.06022698059744327881e+71, 1.05824655795525779205e+71, -1);
+ tcmp2 (1.0, 1.0, 53);
+ for (i = 0; i < 54; i++)
+ {
+ tcmp2 (1.0, 1.0-x, i);
+ x /= 2.0;
+ }
+ for (x = 0.5, i = 1; i < 100; i++)
+ {
+ tcmp2 (1.0, x, 1);
+ x /= 2.0;
+ }
+ for (j = 0; j < 100000; j++)
+ {
+ x = DBL_RAND ();
+ y = DBL_RAND ();
+ if (x < y)
+ {
+ z = x;
+ x = y;
+ y = z;
+ }
+ if (y != 0.0 && y != -0.0)
+ tcmp2 (x, y, -1);
}
tests_end_mpfr ();
+
return 0;
}