Open Manual

Numbers

Choose a numeric type for the range and precision the program needs. Convert at boundaries rather than relying on mixed-width arithmetic. The type rules are in Types.

Prerequisites: basic Nytrix syntax.

Skip this guide if ordinary inferred integers and floating-point values meet your range and precision needs.

Integer types

TypeUse
intDefault signed machine integer (i64 on the documented native ABI).
i8, i16, i32, i64Explicit signed widths.
u8, u16, u32, u64Explicit unsigned widths.
bigintExact integers beyond a fixed-width range.
use core

def i8 small = 7i8
def u16 port = 8080u16
assert_eq(int(small), 7, "explicit integer conversion")

Fixed-width conversions can lose out-of-range information. Check the source range before converting when truncation or wrapping would be incorrect.

For signed 64-bit operations that must report overflow, use core.math.checked. Checked operations return an explicit success/error value; ordinary arithmetic keeps its own operator semantics. Use bigint when the result itself must exceed the machine integer range.

Floating point

f64 is the default floating-point type. Use f32 when the storage or ABI contract requires that width. Floating-point arithmetic is approximate; do not compare independently rounded calculations for exact equality.

use core

def f64 x = 0.1
assert(x > 0.09 && x < 0.11, "range check for decimal")

Exact and extended values

core.math.big provides arbitrary-precision integer helpers; core.math.bigrat provides exact rational arithmetic; and core.math.complex provides complex values. Query the owning module for the constructors, conversion rules, and available operations. Bigfloat helpers called without an explicit precision use the runtime default of 256 significand bits, clamped to the 32..1048576 range. NYTRIX_BIGFLOAT_PRECISION=<bits> overrides that default (the first use caches the value for the remaining run); core.math.big pins its own BF_PRECISION = 256 for its constructors, and bf_with_precision(x, precision) selects per-value precision.

Convert explicitly

FromToForm
intf64f64(value)
literalfixed width7i8, 8080u16, and other sized literal suffixes
strintint(text)
intbigintbigint(value) after importing core.math.big
bigintstrbigint_to_str(value) from core.math.big

Keep ABI types explicit at native boundaries; see Memory.

Vectors and acceleration

core.math.vector provides vector constructors and operations; core.os.gpu provides accelerator APIs. Query their current signatures with:

ny doc get core.math.vector
ny doc get core.os.gpu

Vector types and @accel or @accel(spirv) annotations do not guarantee a speedup. Support depends on the operation and selected target; unsupported shapes produce diagnostics. See Native and function attributes.

Keep a scalar implementation as the correctness reference and measure the same complete workload before adopting a vector path. Assembly output explains lowering, not performance; see Performance.

Next: