1.2 Data Types

1.2.1 Integer Types

The following table summarises the relationship between Rust’s and C++’s integer data types:

Rust C++ C & C++
i8 int8_t char
i16 int16_t short
i32 int32_t int
i64 int64_t long
i128
u8 uint8_t unsigned char
u16 uint16_t unsigned short
u32 uint32_t unsigned int
u64 uint64_t unsigned long
u128
isize
usize size_t

While the equivalence between the first column and the second column always holds true, the third column depends on the platform and here I’m assuming you’re on a modern, 64-bit system.

While the relationships described in the table are always true, C++’s integer types are much more complex. The types above are fixed width integer types, and there are additional integer types whose width is dependent on the implementation. These include C-compatible ones (i.e. char, short, int, long, long long), and other C++ artifects such as int_fast16_t and int_least32_t. You can learn about them at cppreference.

1.2.2 Floating Point Numbers

For floating numbers, f32 and f64 correspond to float and double, respectively (stand for single-precision and double-precision floating point numbers).