(root)/
gmp-6.3.0/
mpf/
dump.c
       1  /* 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  
       8  Copyright 1993-1995, 2000, 2001 Free Software Foundation, Inc.
       9  
      10  This file is part of the GNU MP Library.
      11  
      12  The GNU MP Library is free software; you can redistribute it and/or modify
      13  it 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  
      19  or
      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  
      25  or both in parallel, as here.
      26  
      27  The GNU MP Library is distributed in the hope that it will be useful, but
      28  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
      29  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      30  for more details.
      31  
      32  You should have received copies of the GNU General Public License and the
      33  GNU Lesser General Public License along with the GNU MP Library.  If not,
      34  see https://www.gnu.org/licenses/.  */
      35  
      36  #include <stdio.h>
      37  #include <string.h> /* for strlen */
      38  #include "gmp-impl.h"
      39  
      40  void
      41  mpf_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  }