-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
rand(num) won't work with big_ints #5647
Comments
Hi, In most cases you can work around this by getting a random Int64 or Float64 first |
The hack below at least got the code to compile, but it's sooooo ugly, and probably doesn't have the statistical properties of a real random distribution.
|
Hello. What is the best way to implement random for BigInts @ysbaddaden ? There is some random inside GMP or should I just dance with |
If covering all possible values is not critical, you can work around this with |
And the proper solution would be extending the algorithm to support BigInt (shouldn't be too hard) |
@oprypin Yes, I need the whole range for the cryptographic algorithm. Thanks, I will try to extend this alg. |
* Implement Random for BigInt Fixes crystal-lang#5647 * spec typo fix * Move to big_int.cr * Use to_s in spec * Remove special case of zero because it will be removed in crystal-lang#6686
crystal 0.24.1
translating code from Ruby and hit this bug when doing
when self is big_int
The text was updated successfully, but these errors were encountered: