Numeric Types: Integers and Floats
Explore Rust's numeric types including integers and floating points to clearly understand how to store whole numbers and fractional values. Learn the differences between fixed-size and variable-size integers, and how to correctly define numeric variables for efficient memory use and precise calculations.
We'll cover the following...
Integers
Variables of Integer data type hold whole number values. There are two subtypes of integer data type in Rust, based on the number of bits occupied by a variable in memory.
Fixed Size Types
The fixed integer types have a specific number of bits in their notation. This notation is a combination of a letter and a number. The former denotes the category of the integer, whether it is, unsigned or signed, and the latter denotes the size of an integer, i.e., 8, 16, 32, 64.
Below is the list of fixed length integer types:
-
i8: The 8-bit signed integer type. -
i16: The 16-bit signed integer ...