Skip to main content

Module arith

Module arith 

Source
Expand description

Arithmetic, logical, and bitwise operators.

Constants§

GCOUNTER_TAG
Merge one CRDT field by its convergence rule:

Functions§

add
approx_eq
a is approximately b — the TOLERANT numeric comparison (== is IEEE bit-exact). Both operands coerce to f64 (approximation is inherently tolerant, so the lossy view is correct here) and compare with the ONE shared isclose definition (logicaffeine_data::ops::logos_approx_eq).
binary_op
concat
crdt_counter_bump
One CRDT counter step: current + amount. A CRDT grow-counter is intentionally wrapping (modular) — convergence is defined over the cyclic group, so overflow is a feature here, NOT the silent-corruption footgun that ordinary integer math now promotes away. An absent or Nothing field starts from zero.
crdt_merge_field
crdt_merge_wire
Merge a wire-encoded CRDT value (from crdt_to_wire) into local, field by field through crdt_merge_field — counters add, sets union, registers take the latest. A struct merges each named field; a bare value the unnamed field. Malformed bytes leave local unchanged.
crdt_to_wire
Encode a CRDT value for the relay wire: a JSON object mapping each Int field to its value. A bare Int counter uses the empty field name. Nothing (and any non-counter value) has nothing to publish. The format is browser-friendly and field-addressable, so structs merge field-by-field on the other side.
divide
exact_divide
EXACT division — the runtime of BinaryOpKind::ExactDivide, the type-directed sibling of divide. An evenly-dividing integer pair stays an Int/BigInt; otherwise the quotient is an exact Rational (7 / 2 → 7/2) — it NEVER truncates. A Float operand divides as Float (floats are inexact by choice). This only ever runs where the type says the result is a Rational, so floor code is untouched.
floor_divide
FLOOR division — the runtime of BinaryOpKind::FloorDivide (a // b), the quotient rounded toward NEGATIVE INFINITY. On exact operands (Int/BigInt/Rational/Decimal) the result is the exact quotient’s floor as an integer (-7 // 2 → -4, 10^30 // 7 exact); a Float operand floors the float quotient but stays Float (7.5 // 2 → 3.0, Python semantics). Distinct from divide, which truncates toward zero. Zero divisor is loud.
gcounter_value
The total of a GCOUNTER_TAG counter — the sum of every replica’s count. None for a value that is not a G-Counter.
modulo
multiply
not_value
not x — logical negation of truthiness (Bool out). The bitwise complement is ~.
power
base ** exp — exponentiation. Integer power is EXACT (i64 fast path, promoting to BigInt on overflow); a Float operand takes the f64::powf path; a Rational base with an integer exponent stays exact; a NEGATIVE integer exponent on an integer base is a loud error (an Int can’t hold the fractional result — use a Float base). ONE definition, shared by tw/VM/JIT.
seq_concat
a followed by b — merge two sequences into one fresh sequence. Element order is preserved: all of a, then all of b. Operands must both be sequences.
subtract