C++ GMP Generating Random Number -
i'm trying generate huge random number in c++ using gmp library having issues figuring out syntax. different other examples i've found because need set floor , ceiling random number between. kinda need do:
mpz_class high, low; low = pow(2,199); high = pow(2,210); // code use high , low numbers generate random number
i know isn't go on, again, i'm not sure syntax @ point, i've tried several things nothing i've found enables me tell gmp use high , low range number generation.
thoughts?
function: void mpz_urandomb (mpz_t rop, gmp_randstate_t state, mp_bitcnt_t n)
generate uniformly distributed random integer in range 0 2^n−1, inclusive
so, take 210 - 199, , use n, generate random number , add result pow(2,199).
if want more granular power of 2 upper limit, won't work you. try unsigned int sized random function using same technique above:
— function: unsigned long gmp_urandomm_ui (gmp_randstate_t state, unsigned long n)
return uniformly distributed random number in range 0 n-1, inclusive.
here, find granular range , use n. add random number lower value. limitation n must less maxuint, 2^32 -1
Comments
Post a Comment