I'm looking for an algorithm that allows me generate pseudo-random numbers, but.. How can I the interval of numbers of n-bits? if you have an example for c++ will be great
for example:
BigNumber random(bits 256)
how Can I get the least and the most number of 256 bits
Thanks to all guys, I found the solution
if I have n-bit, the numbers are between (2^n)/2 and (2^n)-1
If the type of random numbers is int, you could use the & operator to mask out unnecessary bits by using a suitable bit mask, e.g. binary 00001111 for the first four bits.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With