Correctness of binary sign operations #
Negation usually changes only the stored sign bit. Formats with unsigned zero are the exception: their would-be negative-zero word is a reserved NaN, so semantic negation preserves both that NaN and the single zero encoding. This module separates raw sign toggling from policy-aware negation and transports the latter through dyadic decoding to the real semantics.
Reference #
- IEEE Standard for Floating-Point Arithmetic, IEEE 754-2019, Sections 3.4 and 5.5.1. https://doi.org/10.1109/IEEESTD.2019.8766229
Toggling an explicitly packed value changes only its supplied sign field.
Packed-field negation toggles the supplied sign when the format represents signed zero.
Copying a sign never changes the fraction field.
Copying a sign never changes the exponent field.
In a signed-zero format, copySign gives the magnitude the source's sign.
Copying a sign preserves NaN classification under every format policy.
Copying a sign preserves zero classification under every format policy.
Copying a sign preserves infinity classification.
Copying a sign preserves finiteness.
Absolute value preserves NaN classification.
Absolute value preserves zero classification.
Absolute value preserves infinity classification.
Absolute value preserves finiteness.
In a signed-zero format, absolute value clears the stored sign.
Policy-aware negation is involutive for every supported encoding.
Negation maps positive zero to the format's policy-selected negative zero.
Negation maps negative zero to positive zero when negative zero is representable.
Negation exchanges the positive and negative IEEE infinity bit patterns in every encoding.
Negation maps the negative IEEE infinity bit pattern to the positive pattern.
The least positive subnormal has sign zero.
The least positive subnormal is finite in every supported encoding.
The least positive subnormal is nonzero.
The least positive subnormal is not a NaN.
The least positive subnormal is not an infinity.
The negative subnormal of least magnitude is explicit field packing with fraction one.
The negative subnormal of least magnitude has sign one.
The negative subnormal of least magnitude is finite in every supported encoding.
The negative subnormal of least magnitude is nonzero.
The negative subnormal of least magnitude is not a NaN.
The negative subnormal of least magnitude is not an infinity.
Negation maps the least positive subnormal to its negative counterpart.
Negation maps the negative subnormal of least magnitude to its positive counterpart.
The largest finite encoding carries exactly the requested sign.
A largest finite encoding is never zero.
A largest finite encoding is never a NaN.
A largest finite encoding is never an infinity.
Negation toggles the sign of the largest finite magnitude.
Negation maps the largest positive finite value to its negative counterpart.
Negation maps the most negative finite value to its positive counterpart.
Negation preserves NaN classification, including the reserved NaN of unsigned-zero formats.
Negation preserves infinity classification.
Negation preserves zero classification.
Negation preserves finiteness.
Flipping the sign flag of a dyadic negates its real value, including for zero significands.
Policy-aware negation decodes to exact dyadic negation with the format's zero convention.
Format-aware dyadic negation is real-number negation.