Copyright (C) 2000-2012 |
GNU Info (gmp.info)I/O of RationalsInput and Output Functions ========================== When using any of these functions, it's a good idea to include `stdio.h' before `gmp.h', since that will allow `gmp.h' to define prototypes for these functions. Passing a `NULL' pointer for a STREAM argument to any of these functions will make them read from `stdin' and write to `stdout', respectively. - Function: size_t mpq_out_str (FILE *STREAM, int BASE, mpq_t OP) Output OP on stdio stream STREAM, as a string of digits in base BASE. The base may vary from 2 to 36. Output is in the form `num/den' or if the denominator is 1 then just `num'. Return the number of bytes written, or if an error occurred, return 0. - Function: size_t mpq_inp_str (mpq_t ROP, FILE *STREAM, int BASE) Read a string of digits from STREAM and convert them to a rational in ROP. Any initial white-space characters are read and discarded. Return the number of characters read (including white space), or 0 if a rational could not be read. The input can be a fraction like `17/63' or just an integer like `123'. Reading stops at the first character not in this form, and white space is not permitted within the string. If the input might not be in canonical form, then `mpq_canonicalize' must be called (Note: Rational Number Functions). The BASE can be between 2 and 36, or can be 0 in which case the leading characters of the string determine the base, `0x' or `0X' for hexadecimal, `0' for octal, or decimal otherwise. The leading characters are examined separately for the numerator and denominator of a fraction, so for instance `0x10/11' is 16/11, whereas `0x10/0x11' is 16/17. automatically generated by info2www version 1.2.2.9 |