This section describes functions for converting GMP integers to standard C types. Functions for converting to GMP integers are described in Assigning Integers and I/O of Integers.
Return the value of op as an
If op is too big to fit an
unsigned longthen just the least significant bits that do fit are returned. The sign of op is ignored, only the absolute value is used.
If op fits into a
signed long intreturn the value of op. Otherwise return the least significant part of op, with the same sign as op.
If op is too big to fit in a
signed long int, the returned result is probably not very useful. To find out if the value will fit, use the function
Convert op to a
double, truncating if necessary (i.e. rounding towards zero).
If the exponent from the conversion is too big, the result is system dependent. An infinity is returned where available. A hardware overflow trap may or may not occur.
Convert op to a
double, truncating if necessary (i.e. rounding towards zero), and returning the exponent separately.
The return value is in the range 0.5<=abs(d)<1 and the exponent is stored to
*exp. d * 2^exp is the (truncated) op value. If op is zero, the return is 0.0 and 0 is stored to
This is similar to the standard C
frexpfunction (see Normalization Functions).
Convert op to a string of digits in base base. The base argument may vary from 2 to 62 or from −2 to −36.
For base in the range 2..36, digits and lower-case letters are used; for −2..−36, digits and upper-case letters are used; for 37..62, digits, upper-case letters, and lower-case letters (in that significance order) are used.
If str is
NULL, the result string is allocated using the current allocation function (see Custom Allocation). The block will be
strlen(str)+1bytes, that being exactly enough for the string and null-terminator.
If str is not
NULL, it should point to a block of storage large enough for the result, that being
) + 2. The two extra bytes are for a possible minus sign, and the null-terminator.
A pointer to the result string is returned, being either the allocated block, or the given str.