big_random
function: mistake in description and better implementation suggestion
#48
Labels
big_random
function: mistake in description and better implementation suggestion
#48
Error in description
I assume that author has written right implementation and forgot about description and not otherwise. So he meant to generate positive
BigInt
s.Then this:
should be changed to
This should be fixed in
include/functions/random.hpp
andREADME.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 generateBigInt
number.BigInt
numberThe text was updated successfully, but these errors were encountered: