1 /* mpf_out_str (stream, base, n_digits, op) -- Print N_DIGITS digits from
2 the float OP to STREAM in base BASE. Return the number of characters
3 written, or 0 if an error occurred.
5 Copyright (C) 1996 Free Software Foundation, Inc.
7 This file is part of the GNU MP Library.
9 The GNU MP Library is free software; you can redistribute it and/or modify
10 it under the terms of the GNU Library General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or (at your
12 option) any later version.
14 The GNU MP Library is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
17 License for more details.
19 You should have received a copy of the GNU Library General Public License
20 along with the GNU MP Library; see the file COPYING.LIB. If not, write to
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 MA 02111-1307, USA. */
30 mpf_out_str (FILE *stream, int base, size_t n_digits, mpf_srcptr op)
32 mpf_out_str (stream, base, n_digits, op)
49 n_digits = (((op->_mp_prec - 1) * BITS_PER_MP_LIMB)
50 * __mp_bases[base].chars_per_bit_exactly);
55 str = (char *) TMP_ALLOC (n_digits + 2); /* extra for minus sign and \0 */
57 mpf_get_str (str, &exp, base, n_digits, op);
58 n_digits = strlen (str);
70 fwrite ("0.", 1, 2, stream);
76 fwret = fwrite (str, 1, n_digits, stream);
83 fpret = fprintf (stream, (base <= 10 ? "e%ld" : "@%ld"), exp);
88 return ferror (stream) ? 0 : written;