blob: cd37dabe62fedc003462e60effd5cf66043b4945 [file] [log] [blame]
Austin Schuhdace2a62020-08-18 10:56:48 -07001/* mpf_dump -- Dump a float to stdout.
2
3 THIS IS AN INTERNAL FUNCTION WITH A MUTABLE INTERFACE. IT IS NOT SAFE TO
4 CALL THIS FUNCTION DIRECTLY. IN FACT, IT IS ALMOST GUARANTEED THAT THIS
5 FUNCTION WILL CHANGE OR DISAPPEAR IN A FUTURE GNU MP RELEASE.
6
7
8Copyright 1993-1995, 2000, 2001 Free Software Foundation, Inc.
9
10This file is part of the GNU MP Library.
11
12The GNU MP Library is free software; you can redistribute it and/or modify
13it under the terms of either:
14
15 * the GNU Lesser General Public License as published by the Free
16 Software Foundation; either version 3 of the License, or (at your
17 option) any later version.
18
19or
20
21 * the GNU General Public License as published by the Free Software
22 Foundation; either version 2 of the License, or (at your option) any
23 later version.
24
25or both in parallel, as here.
26
27The GNU MP Library is distributed in the hope that it will be useful, but
28WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
29or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
30for more details.
31
32You should have received copies of the GNU General Public License and the
33GNU Lesser General Public License along with the GNU MP Library. If not,
34see https://www.gnu.org/licenses/. */
35
36#include <stdio.h>
37#include <string.h> /* for strlen */
38#include "gmp-impl.h"
39
40void
41mpf_dump (mpf_srcptr u)
42{
43 mp_exp_t exp;
44 char *str;
45
46 str = mpf_get_str (0, &exp, 10, 0, u);
47 if (str[0] == '-')
48 printf ("-0.%se%ld\n", str + 1, exp);
49 else
50 printf ("0.%se%ld\n", str, exp);
51 (*__gmp_free_func) (str, strlen (str) + 1);
52}