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
  • string list of bytes
  • rune Unicode scalar values like a 1 4 bytes each (same size as i32)
  • bool either true or values
  • arrays like [10]int
  • slices like []int

  • vectors like [vector 4]f32

  • Dynamic arrays (stretchy buffer) like [dynamic]u32
  • Dynamic maps (hash table) like map[string]int
  • Pointers: rawptr and like ^u8
  • any stores 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`
}

results matching ""

    No results matching ""