BigInt
BigInt copied to clipboard
`big_random` function: mistake in description and better implementation suggestion
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_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 generate- digits in
BigIntnumber. - random length of
BigIntnumber
- digits in
this looks nice, i would like to work on that
let's start, add your suggestions or some code please
anyway, we can't do much without @faheel's attention here
@B1Z0N Sorry for not taking a look at this for almost a year! Your idea seems good. I'll review your PR when I get more time.
And I really don't remember whether the initial intention was to only create positive BigInts or did I forget about negative numbers :smile: