this post was submitted on 24 Dec 2024
33 points (100.0% liked)
Rust
6244 readers
16 users here now
Welcome to the Rust community! This is a place to discuss about the Rust programming language.
Wormhole
Credits
- The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
You shouldn't use modulo to get a random number in a specific range (solution already in another comment). Reason is that numbers below 64 will be twice as likely as number 64-101 (in your example) due to how binary numbers and modulo works.
This is obviously no real issue for this game, just keep in mind that you shouldn't implement something like that (random ranges) yourself, this is especially true for crypto related things.
Thanks, I will keep that in mind.