-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add functions that generate a random BigInt #19
Comments
on which file I have to work to solve this issue? Give me the file name. |
The file |
For reference, the following is the most appropriate way to generate true random numbers C++: std::random_device rand_generator;
size_t rand_int = rand_generator(); // get a random number between 0 and UINT_MAX Using this, one way to generate a random rand_big.value += std::to_string(rand_int); |
Hi, is this issue resolved yet? |
@IbrarYunus I've been working on the second function and it's almost done. You can take up #18 if you're interested in contributing. |
that generates a random BigInt with a specific number of digits
Can I do the function to generate a random number within some range? Have never contributed to any project so i thought some simple function would be good start. |
@FR4NKESTI3N Sure, you can give it a try. |
Sorry, I was unable to work past 2 weeks. I have studied the results of existing big_random() on octave and they appear to be uniformly distributed. Wouldn't it be better to use this existing function with modulo? Something like:
where x can be adjuted to reduce calculations. There dosen't seem to be a need to write an entirely new function unless normal distribution is required. |
Random functions for long long, BigInt, and std::string using specialized Template functions.
@faheel Check out branch GH-19-Random. Let me know if this meets the requirements for this issue and I'll create the Pull Request. |
Is this task still an open issue? If so, I would like to contribute. |
The following functions that generate a random
BigInt
need to be implemented underinclude/functions/random.hpp
:Having specific number of digits:
Returns a random
BigInt
having the specified number of digits. If the number of digits are not specified, use a random value for it.Within a certain range:
Returns a random
BigInt
such thatlow <= BigInt <= high
.Note: type
T
can be aBigInt
,std::string
orlong long
.The text was updated successfully, but these errors were encountered: