| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
6.1 Initialization and Assignment Functions
- Function: void mpq_init (mpq_t x)
Initialize x and set it to 0/1. Each variable should normally only be initialized once, or at least cleared out (using the function
mpq_clear) between each initialization.
- Function: void mpq_inits (mpq_t x, ...)
Initialize a NULL-terminated list of
mpq_tvariables, and set their values to 0/1.
- Function: void mpq_clear (mpq_t x)
Free the space occupied by x. Make sure to call this function for all
mpq_tvariables when you are done with them.
- Function: void mpq_clears (mpq_t x, ...)
Free the space occupied by a NULL-terminated list of
mpq_tvariables.
- Function: void mpq_set (mpq_t rop, const mpq_t op)
- Function: void mpq_set_z (mpq_t rop, const mpz_t op)
Assign rop from op.
- Function: void mpq_set_ui (mpq_t rop, unsigned long int op1, unsigned long int op2)
- Function: void mpq_set_si (mpq_t rop, signed long int op1, unsigned long int op2)
Set the value of rop to op1/op2. Note that if op1 and op2 have common factors, rop has to be passed to
mpq_canonicalizebefore any operations are performed on rop.
- Function: int mpq_set_str (mpq_t rop, const char *str, int base)
Set rop from a null-terminated string str in the given base.
The string can be an integer like “41” or a fraction like “41/152”. The fraction must be in canonical form (see section Rational Number Functions), or if not then
mpq_canonicalizemust be called.The numerator and optional denominator are parsed the same as in
mpz_set_str(see section Assignment Functions). White space is allowed in the string, and is simply ignored. The base can vary from 2 to 62, or if base is 0 then the leading characters are used:0xor0Xfor hex,0bor0Bfor binary,0for octal, or decimal otherwise. Note that this is done separately for the numerator and denominator, so for instance0xEF/100is 239/100, whereas0xEF/0x100is 239/256.The return value is 0 if the entire string is a valid number, or -1 if not.
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on March 31, 2014 using texi2html 5.0.
