Rational
An exact rational number — a numerator/denominator pair over Long, kept reduced to lowest terms with a strictly positive denominator.
The scheduler's virtual times are rationals (b + committedService / weight, design §7.1) and the whole point of the policy is that every replica orders children bit-identically on JVM, Native, and wasmJs. Floating point does not give that — 0.1 + 0.2 is not 0.3 and rounds differently across platforms — so the policy never converts a virtual time to Double/Float. All arithmetic here is exact integer math, reduced after every operation to keep magnitudes small, and overflow-checked: an add or multiply that would exceed Long.MAX_VALUE throws ArithmeticException rather than wrapping to a wrong order (the same discipline as Weight and CheckedMath).
BigInteger would sidestep overflow entirely but is a JVM-only type — unavailable in this module's commonMain — so the exact-but-bounded Long rational is the portable choice; the reduce-after-every-op keeps realistic scheduler workloads far from the ceiling.
Deliberately not @Serializable. The generated serializer would deserialize past of — the only path that reduces and forces a positive denominator — so an unreduced or sign-denormalized value could arrive over the wire and break equals/compareTo exactly as it could for Weight (#1647). Leaving the annotation off makes that unreachable by default: a type that wants to replicate a Rational cannot simply inherit wire-legality, it has to name a normalizing serializer at the property.
No replicated property holds a Rational: a gauge's position is in ticks (#3353), and Gauge's serializer names the retired floor only to refuse it. The normalizing serializer that reads that retired field is internal to this module, so a consumer cannot put a Rational on the wire either. If kuilt ever replicates one, annotate that property with the module's normalizing serializer, never this class: that keeps the default closed.
Properties
Functions
Order by exact cross-multiplication: a/b <=> c/d compares a·d against c·b. Both denominators are positive, so no sign flip is needed. The products are formed in 128 bits, where any two Longs multiply exactly, so every pair of rationals orders and none throws (#3313). A compare that threw used to wedge Gauge.join and every pick that sorts by time.
The exact quotient, reduced. Throws ArithmeticException on division by zero, or when the answer does not fit in Long.
The exact difference, reduced. Throws ArithmeticException only when the answer does not fit.
The exact sum, reduced. Throws ArithmeticException only when the answer does not fit in Long; see combine for why the intermediates never decide that.
The exact product, reduced. Throws ArithmeticException only when the answer does not fit in Long; see crossReduced for why the intermediates never decide that.