I have a c++ BigInteger library. I have to create a bigInteger with exact 125 bit from any large random number. I need to perform rightshift, leftshift, setbit, getbit, NOT, OR, XOR, AND operation on created 125 bit number. Which library i need to use to do above operation? Can anyone please help me.
Share
A google search with the terms
big integer librarygave me the C++ Big Integer Library . From the website:Edit:
To create a random number with 125 bits there are plenty of options.
A simple and quick solution (but obviously not available in the library I posted above – I don’t whether it’s possible with GMP) would be to do a
rand() * 0x1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFin the correct notation.A method in the scope of the above library, which unfortunately is rather slow, would be to draw 125 single bits (“0” or “1” at random) and add increasing powers of 2 if you drew a “1”. Here is some (untested) code: