-
Notifications
You must be signed in to change notification settings - Fork 432
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
gen_range is not able to generate 255 for an u8 type (also applies for other types) #1002
Comments
You could use |
It does work for my use case since it covers the whole number range, however it wouldn't work if I wanted anything smaller such as [10, 255]. |
|
Oh, I see. I'd like to help! Either approach would avoid issues like mine I guess. |
This was fixed with #1003, you can now use |
I'm currently developing a chip8 emulator as a learning experience and one of the instructions requires the generation of a random number between 0 and 255 (inclusive).
I am using
u8
types to represent the number, currently the following code will not compile.I understand that 256 is outside the range of
u8
, however this makes it impossible to generate 255.Bellow I provide a simple example which does not compile.
I'd say that a possible fix would be to provide a function which is inclusive, but I have no idea of possible challenges.
Thank you for your time!
The text was updated successfully, but these errors were encountered: