RationalX Type
A two-tier exact rational packed into 24 bytes: two int64s for the
reduced small-tier numerator/denominator, and a nullable BigCell
reference for the rare spill tier. Big = null means small (value
P/Q); a non-null Big means spilled (value Big.Value).
Hand-rolled (rather than a struct DU) so the spill reference itself is the
small/big discriminator — no DU tag word, so every value is 24 bytes and the
common small case is still inline and allocation-free. There is duplicate logic
for handling spill/non-spill cases, however, for performance reasons this is
accepted.
Canonical-representation invariant: any value that fits int64 is
ALWAYS stored small (Big = null), never spilled. Every constructor and
arithmetic result funnels through OfLarge (which re-narrows) or
normPair. This guarantees a single representation per value, so
equality and hashing are consistent across the two tiers.
Record fields
| Record Field |
Description
|
big tier: null => small (use P/Q); non-null => spilled (use Big.Value)
|
|
Full Usage:
P
Field type: int64
|
small tier: reduced, Q > 0 (the zero-initialized default 0/0 is guarded)
|
Full Usage:
Q
Field type: int64
|
|
Instance members
| Instance member |
Description
|
Full Usage:
this.Denominator
Returns: bigint
|
|
|
|
Full Usage:
this.IsSpilled
Returns: bool
|
True when the value spilled out of the int64 fast path.
|
Full Usage:
this.Numerator
Returns: bigint
|
|
Static members
| Static member |
Description
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GenPRES