|
|
|
@ -58,11 +58,11 @@ error[E0282]: type annotations needed
|
|
|
|
|
|
|
|
|
|
| 数字字面值 | 例子 |
|
|
|
|
|
|------------------|---------------|
|
|
|
|
|
| Decimal | `98_222` |
|
|
|
|
|
| Hex | `0xff` |
|
|
|
|
|
| Octal | `0o77` |
|
|
|
|
|
| Binary | `0b1111_0000` |
|
|
|
|
|
| Byte (`u8` only) | `b'A'` |
|
|
|
|
|
| Decimal (十进制) | `98_222` |
|
|
|
|
|
| Hex (十六进制) | `0xff` |
|
|
|
|
|
| Octal (八进制) | `0o77` |
|
|
|
|
|
| Binary (二进制) | `0b1111_0000` |
|
|
|
|
|
| Byte (单字节字符)(仅限于`u8`) | `b'A'` |
|
|
|
|
|
|
|
|
|
|
那么该使用哪种类型的数字呢?如果拿不定主意,Rust 的默认类型通常就很好,数字类型默认是 `i32`:它通常是最快的,甚至在 64 位系统上也是。`isize` 或 `usize` 主要作为某些集合的索引。
|
|
|
|
|
|
|
|
|
@ -293,4 +293,4 @@ ch02-00-guessing-game-tutorial.html#comparing-the-guess-to-the-secret-number
|
|
|
|
|
[control-flow]: ch03-05-control-flow.html#control-flow
|
|
|
|
|
[strings]: ch08-02-strings.html#storing-utf-8-encoded-text-with-strings
|
|
|
|
|
[unrecoverable-errors-with-panic]: ch09-01-unrecoverable-errors-with-panic.html
|
|
|
|
|
[wrapping]: ../std/num/struct.Wrapping.html
|
|
|
|
|
[wrapping]: ../std/num/struct.Wrapping.html
|
|
|
|
|