Correctness of signed-magnitude dyadic addition #
The runtime aligns dyadic significands and combines their natural-number magnitudes by sign.
Internal.addDyadic_eq identifies this implementation with exact dyadic addition, including
cancellation and the signed-zero rule.
The @[csimp] theorem addDyadic_eq_internal supplies the equality used by the compiler
substitution. The remaining public lemmas describe equal- and adjacent-exponent cases used by
native arithmetic refinements.
Adding equal-exponent dyadics of opposite signs subtracts the smaller magnitude from the larger left one.
The result keeps the sign of the larger magnitude and needs no rounding or exponent adjustment.
Adding equal-exponent dyadics of opposite signs subtracts the smaller left magnitude from the larger right one.
Opposite signs with the larger left operand one exponent higher give 2 * large - small.
Opposite signs with the larger right operand one exponent higher give 2 * large - small.
Align the right dyadic magnitude to the left exponent without changing the exact sum.
Align the left dyadic magnitude to the right exponent without changing the exact sum.
Signed-magnitude dyadic addition equals Model.addDyadic.
Exact dyadic addition is commutative, including its signed-zero rule.
Compiled code runs exact dyadic addition as the signed-magnitude Internal.addDyadic.