[PATCH v2] Replace copysign (0,-1) with -0.0 in initializer
Maciej W. Rozycki
macro@redhat.com
Tue Dec 17 00:47:58 GMT 2024
On Tue, 17 Dec 2024, Joseph Myers wrote:
> > I was not able to track down a definitive standards reference requiring
> > IEEE 754 compiler implementations to respect the sign of zero in literals,
> > would you or anyone else be able to point me at one?
>
> C23 Annex F binds unary '-' to the 'negate' operation (which is defined in
> IEEE 754 as a quiet-computational operation that affects only the sign
> bit, even for NaNs), and specifies that literal conversions (bound to
> convertFromDecimalCharacter, though the detailed syntax is given in the C
> standard) are correctly rounded up to at least CR_DECIMAL_DIG digits.
Thank you. C99/C11 instead just say:
"The unary minus (-) operator provides the unary minus (-) operation
recommended in the Appendix to IEC 60559."
-- would you agree that this is also sufficient for this particular use
case (noting that I reckon IEEE 754 unary minus might be arithmetic at the
implementer's discretion, which doesn't matter for static initialisers
though, and certainly not for 0.0 operand)?
Maciej
More information about the Libc-alpha
mailing list