Skip to main content

Module arith

Module arith 

Source
Expand description

Arithmetic expression evaluation (is/2, comparisons).

Semantics — floored mod, truncating //, float-yielding /, checked i64 overflow, NaN/Infinity rejection, and the exact zero-divisor labels — are pinned by unit tests.

NOTE on the immediate-integer range: cell INT is a 61-bit immediate but eval computes in full i64. A result that fits i64 yet overflows the i61 immediate cannot be boxed until M4; for M3 the is/2 ABI reports it as an error (see pred::plg_rt_b_is). Evaluation itself never narrows — it always works in i64.

Enums§

ArithValue
An evaluated arithmetic value: integer or float.

Functions§

arith_eq
arith_gt
arith_lt
eval
Evaluate expr (a heap word) to an arithmetic value. On Err(()), m.error is already populated with the message text. The unit error type is intentional: the rich error lives in m.error (the M3 ABI contract), so callers only need to know success vs failure.