Explain modulo in the guide.

Fixes 
This commit is contained in:
Steve Klabnik 2014-08-18 15:38:47 -04:00
parent 776c17f476
commit f8a9211740

@ -1888,8 +1888,15 @@ fn main() {
The first thing we changed was to `use std::rand`, as the docs
explained. We then added in a `let` expression to create a variable binding
named `secret_number`, and we printed out its result. Let's try to compile
this using `cargo build`:
named `secret_number`, and we printed out its result.
Also, you may wonder why we are using `%` on the result of `rand::random()`.
This operator is called 'modulo', and it returns the remainder of a division.
By taking the modulo of the result of `rand::random()`, we're limiting the
values to be between 0 and 99. Then, we add one to the result, making it from 1
to 100.
Let's try to compile this using `cargo build`:
```{notrust,no_run}
$ cargo build