Primitives
These are the basic primitive data types found in each language.
C++
Rust
Java
// unsigned values
unsigned char a;
unsigned short b;
unsigned int c;
unsigned long d;
unsigned long long e;
// Boolean values
bool f;
// signed values
char g;
short h;
int i;
long j;
long long k;
// floating point values
float l;
double m;
// unsigned values
let a: u8;
let b: u16;
let c: u32;
let d: u64;
// Boolean values
let e: bool;
// signed values
let f: char;
let g: i8;
let h: i16;
let i: i32;
let j: i64;
// floating point values
let k: f32;
let l: f64;
// Java does not have unsigned values
// Boolean values
boolean a;
// signed values
byte b;
char c;
short d;
int e;
long f;
// floating point values
float g;
double h;
While these are the basic primitive types, you can find special types in C++
that use architecture information to ensure a variable is of a certain size. uint_32
for example will ensure that 32 bits are used to store the value and the value is treated as unsigned.
Rust has the opposite and includes usize
and isize
to provide a variable
that is equal to the address space of the target architecture.