manpagez: man pages & more
info gmp
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.8 Miscellaneous Functions

Function: void mpf_ceil (mpf_t rop, mpf_t op)
Function: void mpf_floor (mpf_t rop, mpf_t op)
Function: void mpf_trunc (mpf_t rop, mpf_t op)

Set rop to op rounded to an integer. mpf_ceil rounds to the next higher integer, mpf_floor to the next lower, and mpf_trunc to the integer towards zero.

Function: int mpf_integer_p (mpf_t op)

Return non-zero if op is an integer.

Function: int mpf_fits_ulong_p (mpf_t op)
Function: int mpf_fits_slong_p (mpf_t op)
Function: int mpf_fits_uint_p (mpf_t op)
Function: int mpf_fits_sint_p (mpf_t op)
Function: int mpf_fits_ushort_p (mpf_t op)
Function: int mpf_fits_sshort_p (mpf_t op)

Return non-zero if op would fit in the respective C data type, when truncated to an integer.

Function: void mpf_urandomb (mpf_t rop, gmp_randstate_t state, mp_bitcnt_t nbits)

Generate a uniformly distributed random float in rop, such that 0 <= rop < 1, with nbits significant bits in the mantissa or less if the precision of rop is smaller.

The variable state must be initialized by calling one of the gmp_randinit functions (Random State Initialization) before invoking this function.

Function: void mpf_random2 (mpf_t rop, mp_size_t max_size, mp_exp_t exp)

Generate a random float of at most max_size limbs, with long strings of zeros and ones in the binary representation. The exponent of the number is in the interval -exp to exp (in limbs). This function is useful for testing functions and algorithms, since these kind of random numbers have proven to be more likely to trigger corner-case bugs. Negative random numbers are generated when max_size is negative.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on February 16, 2012 using texi2html 5.0.