Right shift with sticky-bit jamming #
shiftRightJam is the representation-independent contract used by fixed words, dynamic limbs,
and format-specific rounding kernels. It returns the exact quotient when no discarded bit is set;
otherwise it records the discarded nonzero suffix in the quotient's low bit.
Keeping the operation in Numerics prevents a generic rounding argument from depending on one
particular fixed-word backend.
Shift right and preserve whether any discarded bit was nonzero in the result's low bit.
Exact shifts are unchanged. Inexact shifts return an odd result. This is the proof-facing
definition: it materializes 2^shift to form the quotient and remainder, so fixed-word backends
execute the limb kernels in FloatLib.Kernels (such as UInt256.shiftRightJam128) and use this
definition only as their specification.
Instances For
Exact right shifts are unchanged by jamming.
An inexact right shift with jamming always returns an odd result.
Every bit above the jammed low bit is the corresponding bit of the exact shifted value.
Truncating by at least one more bit therefore gives the same result as a single unjammed shift by the sum of the two shift counts.
Every positive-index bit of a jammed quotient is the corresponding original bit.
A positive-width suffix is nonzero after jamming exactly when the corresponding original suffix was nonzero. This preserves sticky-bit information when shifts are composed.