[BACK]Return to tcmp.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / gmp / mpfr / tests

Annotation of OpenXM_contrib/gmp/mpfr/tests/tcmp.c, Revision 1.1.1.1

1.1       maekawa     1: /* Test file for mpfr_cmp.
                      2:
                      3: Copyright (C) 1999 PolKA project, Inria Lorraine and Loria
                      4:
                      5: This file is part of the MPFR Library.
                      6:
                      7: The MPFR Library is free software; you can redistribute it and/or modify
                      8: it under the terms of the GNU Library General Public License as published by
                      9: the Free Software Foundation; either version 2 of the License, or (at your
                     10: option) any later version.
                     11:
                     12: The MPFR Library is distributed in the hope that it will be useful, but
                     13: WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
                     14: or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
                     15: License for more details.
                     16:
                     17: You should have received a copy of the GNU Library General Public License
                     18: along with the MPFR Library; see the file COPYING.LIB.  If not, write to
                     19: the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
                     20: MA 02111-1307, USA. */
                     21:
                     22: #include <stdio.h>
                     23: #include <stdlib.h>
                     24: #include <math.h>
                     25: #include "gmp.h"
                     26: #include "longlong.h"
                     27: #include "mpfr.h"
                     28: #include "mpfr-impl.h"
                     29:
                     30: int
                     31: main()
                     32: {
                     33:   double x,y; mpfr_t xx,yy; int i,c;
                     34:
                     35:   fprintf(stderr, "Test case 'tcmp' disabled\n");
                     36:   exit(0);                     /* THIS TEST CASE IS NOT WORKING */
                     37:
                     38:   mpfr_init2(xx, 65); mpfr_init2(yy, 65);
                     39:   mpfr_set_str_raw(xx, "0.10011010101000110101010000000011001001001110001011101011111011101E623");
                     40:   mpfr_set_str_raw(yy, "0.10011010101000110101010000000011001001001110001011101011111011100E623");
                     41:   if (mpfr_cmp2(xx,yy)!=64) { printf("Error (1) in mpfr_cmp\n"); exit(1); }
                     42:   mpfr_set_str_raw(xx, "0.10100010001110110111000010001000010011111101000100011101000011100");
                     43:   mpfr_set_str_raw(yy, "0.10100010001110110111000010001000010011111101000100011101000011011");
                     44:   if (mpfr_cmp2(xx,yy)!=64) { printf("Error (1) in mpfr_cmp\n"); exit(1); }
                     45:   mpfr_set_prec(xx,53); mpfr_set_prec(yy,200);
                     46:   mpfr_set_d(xx, 1.0, 0);
                     47:   mpfr_set_d(yy, 1.0, 0);
                     48:   if (mpfr_cmp(xx,yy)!=0) {
                     49:     printf("Error in mpfr_cmp: 1.0 != 1.0\n"); exit(1);
                     50:   }
                     51:   mpfr_set_prec(yy, 31);
                     52:   mpfr_set_d(xx, 1.0000000002, 0);
                     53:   mpfr_set_d(yy, 1.0, 0);
                     54:   if (!(mpfr_cmp(xx,yy)>0)) {
                     55:     printf("Error in mpfr_cmp: not 1.0000000002 > 1.0\n"); exit(1);
                     56:   }
                     57:   mpfr_set_prec(yy, 53);
                     58:   for (i=0;i<1000000;) {
                     59:     x=drand(); y=drand();
                     60:     if (!isnan(x) && !isnan(y)) {
                     61:       i++;
                     62:       mpfr_set_d(xx, x, 0);
                     63:       mpfr_set_d(yy, y, 0);
                     64:       c = mpfr_cmp(xx,yy);
                     65:       if ((c>0 && x<=y) || (c==0 && x!=y) || (c<0 && x>=y)) {
                     66:        printf("Error in mpfr_cmp with x=%1.20e, y=%1.20e mpfr_cmp(x,y)=%d\n",
                     67:               x,y,c); exit(1);
                     68:       }
                     69:     }
                     70:   }
                     71:   mpfr_clear(xx); mpfr_clear(yy);
                     72:   exit (0);
                     73: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>