Shared native signed-magnitude arithmetic #
Binary interchange and posit arithmetic both decode finite values into a sign and an unsigned significand. These one- and two-word operations combine aligned magnitudes, retaining the sign of the larger magnitude on subtraction and choosing positive zero on exact cancellation.
Add or subtract two unsigned magnitudes according to their independent signs.
Exact cancellation returns positive zero. Same-sign callers must establish separately that the
sum fits in UInt64; opposite-sign subtraction cannot overflow.
Instances For
Add or subtract two unsigned two-limb magnitudes according to their independent signs.
Exact cancellation returns positive zero. Same-sign addition discards the carry from add128,
so callers must establish that the sum fits in UInt128; opposite-sign subtraction cannot overflow.