Error in description
I assume that author has written right implementation and forgot about description and not otherwise. So he meant to generate positive BigInts.
Then this:
Returns a random BigInt with a specific number of digits
should be changed to
Returns a random positive BigInt with a specific number of digits
This should be fixed in include/functions/random.hpp and README.md.
Better implementation
-
std::random_device is used to generate random digits, but it is not intended to be used that way for general purposes(read this). So I suggest to use the modern way - std::mt19937. Properly seeded it has 2^19937-1 potential states(that's a lot).
-
When we are using % operation to achieve uniform integer distribution, that's not the right way, because some numbers are more likely to come up(read this for example). So let's use the right and modern way - std::uniform_int_distribution to generate
- digits in
BigInt number.
- random length of
BigInt number
Error in description
I assume that author has written right implementation and forgot about description and not otherwise. So he meant to generate positive
BigInts.Then this:
should be changed to
This should be fixed in
include/functions/random.hppandREADME.md.Better implementation
std::random_deviceis used to generate random digits, but it is not intended to be used that way for general purposes(read this). So I suggest to use the modern way -std::mt19937. Properly seeded it has 2^19937-1 potential states(that's a lot).When we are using
%operation to achieve uniform integer distribution, that's not the right way, because some numbers are more likely to come up(read this for example). So let's use the right and modern way -std::uniform_int_distributionto generateBigIntnumber.BigIntnumber