-
Notifications
You must be signed in to change notification settings - Fork 22
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
Fix random bugs #6
Conversation
It should probably still panic if |
@Sc00bz it's not a valid range, but I don't think the panic is useful. |
Well setting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. The two fixes and the name cleanup are good things.
I do want consider what the proper behavior should be on a division by zero, but let's make that a separate issue.
b := make([]byte, 8) | ||
// randomUint32 creates a random 32 bit unsigned integer | ||
func randomUint32() uint32 { | ||
b := make([]byte, 4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I'm not sure why I originally had 8 in there. Probably because I can't do arithmetic.
// Based on Int31n from the math/rand package.. | ||
func randomUint32n(n uint32) uint32 { | ||
if n <= 1 { | ||
return 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that we need to figure out more carefully what we want to happen in this case. This choice is fine for now, but we should create a separate issue for this.
Fixes #5
int31n
.Thanks, @Sc00bz!