Mathematics
Math is a builtin namespace, available without an import. There is no separate math package to add to a project. The Math namespace reference contains function names, numeric widths, constants, and examples.
Choose the numeric operation first
For scalar floating-point work, select the required precision explicitly:
let root: f64 = Math.sqrt(144.0); // 12.0
let root32: f32 = Math.sqrtf(144.0 as f32);
let angle: f64 = Math.PI / 4.0;
let sine: f64 = Math.sin(angle);The unsuffixed transcendental operations use the f64 family; explicitly supported f spellings, such as sqrtf, select f32. Not every function has an f spelling. Constants include Math.PI, Math.E, Math.TAU and Math.SQRT2. Float classification uses Math.isNaN, Math.isInf, and Math.isFinite with that capitalization.
GPU and SIMD Acceleration
Supported array and Tensor calls express elementwise work. The operation, number type, shape, compiler path, and target determine whether it lowers to vector instructions, scalar operations, library calls, or an accelerator kernel. For example, a semantic sine operation does not imply a CPU instruction that calculates every lane's sine in one cycle.
Graph Functions
Inside a graph fn, supported math operations participate in SIR composition. The graph must still satisfy the selected backend's operation and precision rules. A graph declaration alone does not establish GPU dispatch, transfer-free execution, or numerical equivalence across devices. See the SIMD/SIMT contract.
Exact float representation
Math.toBits and Math.fromBits reinterpret scalar representations:
let negativeZero: f64 = Math.fromBits(0x8000000000000000 as u64);
let bits: u64 = Math.toBits(negativeZero); // 0x8000000000000000The accepted pairs are f32/u32 and f64/u64. This is not a numeric cast; it preserves signed zero and NaN payload bits. Signed integers and mismatched widths are rejected. Subsequent floating-point arithmetic may have different NaN behavior, so preserve the integer bits when exact representation is the goal.