trpl-zh-cn/listings/ch03-common-programming-concepts/no-listing-07-numeric-operations/src/main.rs

18 lines
269 B
Rust
Raw Normal View History

2022-02-06 16:43:51 +08:00
fn main() {
2022-02-06 22:46:20 +08:00
// 加法
2022-02-06 16:43:51 +08:00
let sum = 5 + 10;
2022-02-06 22:46:20 +08:00
// 减法
2022-02-06 16:43:51 +08:00
let difference = 95.5 - 4.3;
2022-02-06 22:46:20 +08:00
// 乘法
2022-02-06 16:43:51 +08:00
let product = 4 * 30;
2022-02-06 22:46:20 +08:00
// 除法
2022-02-06 16:43:51 +08:00
let quotient = 56.7 / 32.2;
2022-02-06 22:46:20 +08:00
let floored = 2 / 3; // 结果为 0
2022-02-06 16:43:51 +08:00
2022-02-06 22:46:20 +08:00
// 取余
2022-02-06 16:43:51 +08:00
let remainder = 43 % 5;
}