Primitive Types

Integer Types

Signed Integers

TypeSizeMinMax
i88-bit-128127
i1616-bit-32,76832,767
i3232-bit-2,147,483,6482,147,483,647
i6464-bit-9.2 * 10^189.2 * 10^18
isizepointer-sizedPlatform dependentPlatform dependent

Unsigned Integers

TypeSizeMinMax
u88-bit0255
u1616-bit065,535
u3232-bit04,294,967,295
u6464-bit01.8 * 10^19
usizepointer-sized0Platform dependent

Integer Methods

let x: i32 = 42;
let s = x.to_string();      // "42"
let abs = x.abs();           // absolute value
let min = x.min(10);         // minimum of two values
let max = x.max(100);        // maximum of two values

Integer Literals

let dec = 42;            // decimal
let hex = 0xFF;          // hexadecimal
let oct = 0o77;          // octal
let bin = 0b1010;        // binary
let with_sep = 1_000_000; // underscore separator
let typed = 42u8;        // type suffix

Floating-Point Types

TypeSizePrecisionRangeEnergy
f1616-bit~3 digits~6.1 * 10^-5 to 655040.4 pJ
bf1616-bit~3 digits~1.2 * 10^-38 to ~3.4 * 10^380.4 pJ
f3232-bit~7 digits~1.2 * 10^-38 to ~3.4 * 10^380.35 pJ
f6464-bit~15 digits~2.2 * 10^-308 to ~1.8 * 10^3080.35 pJ

Half-Precision Types

f16 is IEEE 754 half-precision — useful for signal processing and inference where memory bandwidth matters more than precision.

bf16 (Brain Float) has the same exponent range as f32 but only 8 mantissa bits. Designed for ML training where gradients don't need full precision. Used natively on Google TPUs, NVIDIA A100+, and Apple Neural Engine.

let weight: f16 = 0.5f16;
let grad: bf16 = 0.001bf16;

// Convert to/from f32
let full: f32 = weight as f32;
let half: f16 = full as f16;

Float Methods

let x: f64 = 3.14;
let s = x.to_string();      // "3.14"
let abs = x.abs();           // absolute value
let sqrt = x.sqrt();         // square root
let floor = x.floor();       // round down
let ceil = x.ceil();         // round up
let round = x.round();       // round to nearest

Float Literals

let a = 3.14;           // f64 (default)
let b = 3.14f32;        // f32
let c = 1.0e10;         // scientific notation
let d = 2.5e-3;         // 0.0025

Boolean

let t: bool = true;
let f: bool = false;

Boolean Operations

let and = a && b;       // logical AND (short-circuit)
let or = a || b;        // logical OR (short-circuit)
let not = !a;            // logical NOT

Character

A Unicode scalar value (4 bytes):

let c: char = 'A';
let emoji: char = '\u{1F600}';
let newline: char = '\n';

Unit Type

The unit type () represents no meaningful value:

fn do_something() {
    // implicitly returns ()
}

let unit: () = ();

Type Conversions

Use as for numeric conversions:

let i: i32 = 42;
let f: f64 = i as f64;       // 42.0
let u: u8 = i as u8;         // 42 (truncates if > 255)
let s: usize = i as usize;   // 42

Conversions are explicit -- Joule does not implicitly convert between numeric types.