2 Primitive Types
Odin supports a wide variety of basic or primitive types. A small collection includes:
- Signed integers:
i8,i16,i32,i64,i128,int(pointer size) - Unsigned integers:
u8,u16,u32,u64,u128,uint(pointer size) - Floating point:
f32,f64 - Complex numbers:
complex64,complex128 - Extend complex numbers:
quaternion128,quaternion256 stringlist of bytesruneUnicode scalar values likea1树4 bytes each (same size asi32)booleithertrueorvalues- arrays like
[10]int slices like
[]intvectors like
[vector 4]f32- Dynamic arrays (stretchy buffer) like
[dynamic]u32 - Dynamic maps (hash table) like
map[string]int - Pointers:
rawptrand like^u8 anystores a pointer to the data and its type information
Variables and constants can be type annotated.
main :: proc() {
condition: bool = true;
a_float: f64 = 1;
an_integer: i32 = 2;
default_float := 3.0; // `f64` default type
default_integer := 4; // `int`
}