This lesson talks about Integer types in Rust and that there are unsigned and signed integers.
It also explains how every the type names are composed of "u" and "i", for unsigned and signed respectively, followed by their with in bits. So u8
is an unsigned integer that can store values up to 8 bits (0 - 255).
#[allow(warnings)]
fn main() {
// Unsigned integer types:
//
// u8: 0 to 2^8 (255)
// u16: 0 to 2^16 (65,535)
// u32: 0 to 2^32 (4,294,967,295)
// u64: 0 to 2^64 (really big number)
// usize: 0 to 2^32-1 or 2^64-1
// Signed integer types:
//
// i8: -2^7 to 2^7-1 (-128 to 127)
// i16: -2^15 to 2^15-1 (-32,768 to 32,767)
// i32: -2^31 to 2^31-1 (super negative to super positive)
// i64: -2^63 to 2^63-1 (you get the idea)
// isize: -2^31-1 or -2^63-1 to 2^31-1 or 2^63-1
let number: u8 = 0;
}
标签:u8,32,31,unsigned,63,Rust,Integer,Types From: https://www.cnblogs.com/Answer1215/p/18022005