(gmp.info.gz) Converting Integers
Info Catalog
(gmp.info.gz) Simultaneous Integer Init & Assign
(gmp.info.gz) Integer Functions
(gmp.info.gz) Integer Arithmetic
Conversion Functions
====================
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.
- Function: unsigned long int mpz_get_ui (mpz_t OP)
Return the value of OP as an `unsigned long'.
If OP is too big to fit an `unsigned long' then just the least
significant bits that do fit are returned. The sign of OP is
ignored, only the absolute value is used.
- Function: signed long int mpz_get_si (mpz_t OP)
If OP fits into a `signed long int' return 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 `mpz_fits_slong_p'.
- Function: double mpz_get_d (mpz_t OP)
Convert OP to a `double', truncating if necessary (ie. 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.
- Function: double mpz_get_d_2exp (signed long int *EXP, mpz_t OP)
Convert OP to a `double', truncating if necessary (ie. 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 `*EXP'.
This is similar to the standard C `frexp' function (
Normalization Functions (libc)Normalization Functions.).
- Function: char * mpz_get_str (char *STR, int BASE, mpz_t OP)
Convert OP to a string of digits in base BASE. The base may vary
from 2 to 36.
If STR is `NULL', the result string is allocated using the current
allocation function ( Custom Allocation). The block will be
`strlen(str)+1' bytes, 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 `mpz_sizeinbase (OP, BASE) + 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.
Info Catalog
(gmp.info.gz) Simultaneous Integer Init & Assign
(gmp.info.gz) Integer Functions
(gmp.info.gz) Integer Arithmetic
automatically generated byinfo2html