GNU Info

Info Node: (gmp.info)I/O of Floats

(gmp.info)I/O of Floats


Next: Miscellaneous Float Functions Prev: Float Comparison Up: Floating-point Functions
Enter node , (file) or (file)node

Input and Output Functions
==========================

   Functions that perform input from a stdio stream, and functions that
output to a stdio stream.  Passing a `NULL' pointer for a STREAM
argument to any of these functions will make them read from `stdin' and
write to `stdout', respectively.

   When using any of these functions, it is a good idea to include
`stdio.h' before `gmp.h', since that will allow `gmp.h' to define
prototypes for these functions.

 - Function: size_t mpf_out_str (FILE *STREAM, int BASE, size_t
          N_DIGITS, mpf_t OP)
     Print OP to STREAM, as a string of digits.  Return the number of
     bytes written, or if an error occurred, return 0.

     The mantissa is prefixed with an `0.' and is in the given BASE,
     which may vary from 2 to 36.  An exponent then printed, separated
     by an `e', or if BASE is greater than 10 then by an `@'.  The
     exponent is always in decimal.  The decimal point follows the
     current locale, on systems providing `localeconv'.

     Up to N_DIGITS will be printed from the mantissa, except that no
     more digits than are accurately representable by OP will be
     printed.  N_DIGITS can be 0 to select that accurate maximum.

 - Function: size_t mpf_inp_str (mpf_t ROP, FILE *STREAM, int BASE)
     Read a string in base BASE from STREAM, and put the read float in
     ROP.  The string is of the form `M@N' or, if the base is 10 or
     less, alternatively `MeN'.  `M' is the mantissa and `N' is the
     exponent.  The mantissa is always in the specified base.  The
     exponent is either in the specified base or, if BASE is negative,
     in decimal.  The decimal point expected is taken from the current
     locale, on systems providing `localeconv'.

     The argument BASE may be in the ranges 2 to 36, or -36 to -2.
     Negative values are used to specify that the exponent is in
     decimal.

     Unlike the corresponding `mpz' function, the base will not be
     determined from the leading characters of the string if BASE is 0.
     This is so that numbers like `0.23' are not interpreted as octal.

     Return the number of bytes read, or if an error occurred, return 0.


automatically generated by info2www version 1.2.2.9