mirror of
https://github.com/rust-lang/book.git
synced 2026-11-30 21:31:17 -06:00
@@ -78,7 +78,7 @@ the scope of this book).
|
|||||||
|
|
||||||
Each signed variant can store numbers from -(2<sup>n - 1</sup>) to 2<sup>n -
|
Each signed variant can store numbers from -(2<sup>n - 1</sup>) to 2<sup>n -
|
||||||
1</sup> - 1 inclusive, where `n` is the number of bits that variant uses. So an
|
1</sup> - 1 inclusive, where `n` is the number of bits that variant uses. So an
|
||||||
`i8` can store numbers from -(2<sup>7</sup>) to 2<sup>7</sup>, which equals
|
`i8` can store numbers from -(2<sup>7</sup>) to 2<sup>7</sup> - 1, which equals
|
||||||
-128 to 127. Unsigned variants can store numbers from 0 to 2<sup>n</sup> - 1,
|
-128 to 127. Unsigned variants can store numbers from 0 to 2<sup>n</sup> - 1,
|
||||||
so a `u8` can store numbers from 0 to 2<sup>8</sup> - 1, which equals 0 to 255.
|
so a `u8` can store numbers from 0 to 2<sup>8</sup> - 1, which equals 0 to 255.
|
||||||
|
|
||||||
|
|||||||
@@ -35,12 +35,12 @@ condition. In this case, the condition checks whether or not the variable
|
|||||||
condition is true is placed immediately after the condition inside curly
|
condition is true is placed immediately after the condition inside curly
|
||||||
braces. Blocks of code associated with the conditions in `if` expressions are
|
braces. Blocks of code associated with the conditions in `if` expressions are
|
||||||
sometimes called *arms*, just like the arms in `match` expressions that we
|
sometimes called *arms*, just like the arms in `match` expressions that we
|
||||||
discussed in the “Comparing the Guess to the Secret Number” section of Chapter
|
discussed in the “Comparing the Guess to the Secret Number” section of
|
||||||
2. Optionally, we can also include an `else` expression, which we chose to do
|
Chapter 2. Optionally, we can also include an `else` expression, which we chose
|
||||||
here, to give the program an alternative block of code to execute should the
|
to do here, to give the program an alternative block of code to execute should
|
||||||
condition evaluate to false. If you don’t provide an `else` expression and the
|
the condition evaluate to false. If you don’t provide an `else` expression and
|
||||||
condition is false, the program will just skip the `if` block and move on to
|
the condition is false, the program will just skip the `if` block and move on
|
||||||
the next bit of code.
|
to the next bit of code.
|
||||||
|
|
||||||
Try running this code; you should see the following output:
|
Try running this code; you should see the following output:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user