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

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

1.1       maekawa     1: /* Test file for mpfr_set_d and mpfr_get_d.
                      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 <time.h>
                     25: #ifdef IRIX64
                     26: #include <sys/fpu.h>
                     27: #endif
                     28: #include "gmp.h"
                     29: #include "mpfr.h"
                     30: #include "mpfr-impl.h"
                     31:
                     32: extern int isnan();
                     33:
                     34: int
                     35: main(int argc, char **argv)
                     36: {
                     37:   fprintf(stderr, "Test case tset_d disabled\n");
                     38:   exit(0);                     /* THIS TEST CASE IS NOT WORKING */
                     39:
                     40: #if 0
                     41:   mpfr_t x,y,z; unsigned long k,n; double d, dd;
                     42: #ifdef IRIX64
                     43:     /* to get denormalized numbers on IRIX64 */
                     44:     union fpc_csr exp;
                     45:     exp.fc_word = get_fpc_csr();
                     46:     exp.fc_struct.flush = 0;
                     47:     set_fpc_csr(exp.fc_word);
                     48: #endif
                     49:
                     50:   mpfr_init2(z, 32);
                     51:   mpfr_set_d(z, 1.0, 0);
                     52:   if (mpfr_get_d(z) != 1.0) {
                     53:     mpfr_print_raw(z); putchar('\n');
                     54:     printf("Error: 1.0 != 1.0\n"); exit(1);
                     55:   }
                     56:   mpfr_init2(x, 53); mpfr_init2(y, 53);
                     57:   mpfr_set_d(x, d=-1.08007920352320089721e+150, 0);
                     58:   if (mpfr_get_d(x) != d) {
                     59:     mpfr_print_raw(x); putchar('\n');
                     60:     printf("Error: get_d o set_d <> identity for d = %1.20e %1.20e\n",d,
                     61:           mpfr_get_d(x)); exit(1);
                     62:   }
                     63:   srand48(time(NULL));
                     64:   mpfr_set_d(x, 8.06294740693074521573e-310, 0);
                     65:   d = -6.72658901114033715233e-165;
                     66:   mpfr_set_d(x, d, 0);
                     67:   if (d != mpfr_get_d(x)) {
                     68:     mpfr_print_raw(x); putchar('\n');
                     69:     printf("Error: get_d o set_d <> identity for d = %1.20e %1.20e\n",d,
                     70:           mpfr_get_d(x)); exit(1);
                     71:   }
                     72:   n = (argc==1) ? 1000000 : atoi(argv[1]);
                     73:   for (k = 1; k <= n; k++)
                     74:     {
                     75:       d = drand();
                     76:       mpfr_set_d(x, d, 0);
                     77:       dd = mpfr_get_d(x);
                     78:       if (d != dd && (!isnan(d) || !isnan(dd)))
                     79:        {
                     80:          fprintf(stderr,
                     81:                  "Mismatch on : %1.18g != %1.18g\n", d, mpfr_get_d(x));
                     82:          mpfr_print_raw(x); putchar('\n');
                     83:        }
                     84:     }
                     85:
                     86:   mpfr_clear(x); mpfr_clear(y); mpfr_clear(z);
                     87:   exit (0);
                     88: #endif /* 0 */
                     89: }
                     90:

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