Skip to content

Latest commit

 

History

History

scalar-types

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Scalar types

Rust has several scalar types that represent basic values and data structures. These types are built into the language and do not require any additional dependencies or libraries to use.

Boolean (bool): Represents a logical value, either true or false.

let a: bool = true;

Signed integers (i8, i16, i32, i64, i128): Represent whole numbers that can be positive or negative. The number after the 'i' represents the number of bits the integer type uses.

let a: i8 = 1;
let b: i16 = 1;
let c: i32 = 1;
let d: i64 = 1;
let e: i128 = 1;

Unsigned integers (u8, u16, u32, u64, u128): Represent whole numbers that can only be positive. The number after the 'u' represents the number of bits the integer type uses.

let a: u8 = 1;
let b: u16 = 1;
let c: u32 = 1;
let d: u64 = 1;
let e: u128 = 1;

Floating-point numbers (f32, f64): Represent decimal numbers with single or double precision.

let a: f32 = 1.0;
let b: f64 = 1.0;

Character (char): Represents a single Unicode character.

let a: char = 'a';