about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-08-19 13:05:52 +0000
committerbors <bors@rust-lang.org>2014-08-19 13:05:52 +0000
commitef0d49d78f91d6e517af2e37ed89a3e3587b9f83 (patch)
tree394465f3abc8ab675c3c51dad09596ccd67dcf8b
parent3570095e34c58d5f40a3f81f4c970975befebe54 (diff)
parentc88feffde4f5043adf07a6837026f228e20b67e6 (diff)
auto merge of #16585 : steveklabnik/rust/random_remarks, r=pcwalton
Fixes #15954 and #16354.
-rw-r--r--src/doc/guide.md12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/doc/guide.md b/src/doc/guide.md
index ad44e55e57d..94c77efc94d 100644
--- a/src/doc/guide.md
+++ b/src/doc/guide.md
@@ -1888,8 +1888,16 @@ 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. Using modulo can give you a very, very small bias in the result, but
+for this example, it is not important.
+
+Let's try to compile this using `cargo build`:
 
 ```{notrust,no_run}
 $ cargo build