I wanted to talk about basic types in Rust. Lets begin with Numerical Types in Rust, since Rust is a statically typed language, which means that it must know the types of all variables at compile time. I will talk about number types that are built into the language.

Numerical Types

Numerical values are divided into Integer Types and Floating-point type. A simple numerical type can be signed integer types or unsigned integer types.

Signed integer types start with i instead of u

Integer Data types are listed below:

  • i8 : The 8-bit signed integer type.
  • i16 : The 16-bit signed integer type.
  • i32 : The 32-bit signed integer type.
  • i64 : The 64-bit signed integer type.
  • u8 : The 8-bit unsigned integer type.
  • u16 : The 16-bit unsigned integer type.
  • u32 : The 32-bit unsigned integer type.
  • u64 : The 64-bit unsigned integer type.
  • isize : The pointer-sized signed integer type.
  • usize : The pointer-sized unsigned integer type.
Type MAX MIN
i8 127 -128
i16 32767 -32768
i32 2147483647 -2147483648
i64 9223372036854775807 -9223372036854775808
i128 170141183460469231731687303715884105727 -170141183460469231731687303715884105728
u8 0 255
u16 0 65535
u32 0 4294967295
u64 0 18446744073709551615
u128 0 340282366920938463463374607431768211455

Floating Point data types are simplier, there is only 2 types.

  • f32 : The 32-bit floating point type.
  • 64 : The 64-bit floating point type.

Summary

This was a short intro to the numerical values and the limits of each value in Rust.