Annotation of OpenXM_contrib/gmp/mpfr/dump.c, Revision 1.1
1.1 ! ohara 1: /* mpfr_dump -- Dump a float to stdout.
! 2:
! 3: Copyright 1999, 2001 Free Software Foundation, Inc.
! 4: (Copied from the GNU MP Library.)
! 5:
! 6: This file is part of the MPFR Library.
! 7:
! 8: The MPFR Library is free software; you can redistribute it and/or modify
! 9: it under the terms of the GNU Lesser General Public License as published by
! 10: the Free Software Foundation; either version 2.1 of the License, or (at your
! 11: option) any later version.
! 12:
! 13: The MPFR Library is distributed in the hope that it will be useful, but
! 14: WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
! 15: or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
! 16: License for more details.
! 17:
! 18: You should have received a copy of the GNU Lesser General Public License
! 19: along with the MPFR Library; see the file COPYING.LIB. If not, write to
! 20: the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
! 21: MA 02111-1307, USA. */
! 22:
! 23: #include <stdio.h>
! 24: #include <string.h>
! 25: #include "gmp.h"
! 26: #include "gmp-impl.h"
! 27: #include "mpfr.h"
! 28: #include "mpfr-impl.h"
! 29:
! 30: void
! 31: mpfr_dump (mpfr_srcptr u, mp_rnd_t rnd_mode)
! 32: {
! 33: mp_exp_t exp;
! 34: char *str;
! 35:
! 36: if (MPFR_IS_NAN(u))
! 37: {
! 38: printf ("NaN\n");
! 39: return;
! 40: }
! 41:
! 42: if (MPFR_IS_INF(u))
! 43: {
! 44: if (MPFR_SIGN(u) == 1)
! 45: printf ("Inf\n");
! 46: else
! 47: printf ("-Inf\n");
! 48: return;
! 49: }
! 50:
! 51: str = mpfr_get_str (NULL, &exp, 10, 0, u, rnd_mode);
! 52: if (str[0] == '-')
! 53: printf ("-0.%se%ld\n", str + 1, exp);
! 54: else
! 55: printf ("0.%se%ld\n", str, exp);
! 56: (*__gmp_free_func) (str, strlen(str)+1);
! 57: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>