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

Annotation of OpenXM_contrib/gmp/mpfr/tests/tisnan.c, Revision 1.1

1.1     ! ohara       1: /* Test file for mpfr_nan_p, mpfr_inf_p and mpfr_number_p.
        !             2:
        !             3: Copyright 2001 Free Software Foundation.
        !             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 Lesser General Public License as published by
        !             9: the Free Software Foundation; either version 2.1 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 Lesser General Public
        !            15: License for more details.
        !            16:
        !            17: You should have received a copy of the GNU Lesser 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 "gmp.h"
        !            25: #include "mpfr.h"
        !            26:
        !            27: int
        !            28: main (void)
        !            29: {
        !            30:   mpfr_t  x;
        !            31:
        !            32:   mpfr_init (x);
        !            33:
        !            34:   /* check +infinity gives non-zero for mpfr_inf_p only */
        !            35:   mpfr_set_ui (x, 1L, GMP_RNDZ);
        !            36:   mpfr_div_ui (x, x, 0L, GMP_RNDZ);
        !            37:   if (mpfr_nan_p (x)) {
        !            38:     fprintf (stderr, "Error: mpfr_nan_p(+Inf) gives non-zero\n");
        !            39:     exit (1);
        !            40:   }
        !            41:   if (mpfr_inf_p (x) == 0) {
        !            42:     fprintf (stderr, "Error: mpfr_inf_p(+Inf) gives zero\n");
        !            43:     exit (1);
        !            44:   }
        !            45:   if (mpfr_number_p (x)) {
        !            46:     fprintf (stderr, "Error: mpfr_number_p(+Inf) gives non-zero\n");
        !            47:     exit (1);
        !            48:   }
        !            49:
        !            50:   /* same for -Inf */
        !            51:   mpfr_neg (x, x, GMP_RNDN);
        !            52:   if (mpfr_nan_p (x)) {
        !            53:     fprintf (stderr, "Error: mpfr_nan_p(-Inf) gives non-zero\n");
        !            54:     exit (1);
        !            55:   }
        !            56:   if (mpfr_inf_p (x) == 0) {
        !            57:     fprintf (stderr, "Error: mpfr_inf_p(-Inf) gives zero\n");
        !            58:     exit (1);
        !            59:   }
        !            60:   if (mpfr_number_p (x)) {
        !            61:     fprintf (stderr, "Error: mpfr_number_p(-Inf) gives non-zero\n");
        !            62:     exit (1);
        !            63:   }
        !            64:
        !            65:   /* same for NaN */
        !            66:   mpfr_sub (x, x, x, GMP_RNDN);
        !            67:   if (mpfr_nan_p (x) == 0) {
        !            68:     fprintf (stderr, "Error: mpfr_nan_p(NaN) gives zero\n");
        !            69:     exit (1);
        !            70:   }
        !            71:   if (mpfr_inf_p (x)) {
        !            72:     fprintf (stderr, "Error: mpfr_inf_p(NaN) gives non-zero\n");
        !            73:     exit (1);
        !            74:   }
        !            75:   if (mpfr_number_p (x)) {
        !            76:     fprintf (stderr, "Error: mpfr_number_p(NaN) gives non-zero\n");
        !            77:     exit (1);
        !            78:   }
        !            79:
        !            80:   /* same for an ordinary number */
        !            81:   mpfr_set_ui (x, 1, GMP_RNDN);
        !            82:   if (mpfr_nan_p (x)) {
        !            83:     fprintf (stderr, "Error: mpfr_nan_p(1) gives non-zero\n");
        !            84:     exit (1);
        !            85:   }
        !            86:   if (mpfr_inf_p (x)) {
        !            87:     fprintf (stderr, "Error: mpfr_inf_p(1) gives non-zero\n");
        !            88:     exit (1);
        !            89:   }
        !            90:   if (mpfr_number_p (x) == 0) {
        !            91:     fprintf (stderr, "Error: mpfr_number_p(1) gives zero\n");
        !            92:     exit (1);
        !            93:   }
        !            94:
        !            95:   mpfr_clear (x);
        !            96:
        !            97:   return 0;
        !            98: }

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