- i32
- i64
Rust numerical types
- By default numbers are stored in i32 whose range is -2147483648..=2147483647
- We can explicitely put numbers in different types
examples/types/number-types/src/main.rs
fn main() { let x = 300_000_000; // let x = 3000000000; // note: the literal `3000000000` does not fit into the type `i32` whose range is `-2147483648..=2147483647` let y: i64 = 3_000_000_000; println!("{}", x); println!("{}", y); println!("{}", x+y); }
examples/types/numbers/src/main.rs
fn main() { let x = 2.1; let y = 3.4; println!("{}", x + y); }
- List of Rusts primitive types