I'm trying to generate a huge random number in C++ using the GMP library but am having issues figuring out the syntax. This is slightly different from other examples I've found because I need to set a floor and ceiling for the random number to be between. This is kinda what I need to do:
mpz_class high, low;
low = pow(2,199);
high = pow(2,210);
// code to use the high and low numbers to generate the random number
I know this isn't much to go on, but again, I'm not sure what the syntax would even be at this point, I've tried several things but nothing I've found enables me to tell GMP to use a high and low range for the number generation.
Thoughts?
From Gmp Lib Documentation
So, take 210 - 199, and use that as n, generate a random number and add the result to pow(2,199).
If you want something more granular than a power of 2 upper limit, this won't work for you. You could try the unsigned int sized random function using the same technique above:
Here, you would find your granular range and use that for n. Then add the random number to your lower value. The limitation is n must be less than MAXUINT, usually 2^32 -1