[PATCH v2] Replace copysign (0,-1) with -0.0 in initializer
Maciej W. Rozycki
macro@redhat.com
Tue Dec 17 00:03:07 GMT 2024
On Tue, 17 Dec 2024, H.J. Lu wrote:
> > OK but let's see what Maciej says.
>
> There are other places where -0.0 is used:
>
> stdlib/strtod_l.c: RETURN (negative ? -0.0 : 0.0,
> stdlib/strtod_l.c: RETURN (negative ? -0.0 : 0.0, tp);
> stdlib/strtod_l.c: result = negative ? -0.0 : 0.0;
> stdlib/strtod_l.c: return negative ? -0.0 : 0.0;
Thank you for the reference, however existing use may not be sufficient
an argument.
The sign of 0.0 doesn't matter in many computational scenarios (of course
it does in some or we wouldn't have it), and the purpose of these test
cases is to exercise standards compliance of output conversion where the
sign does matter, rather than the numeric value where it may or may not.
Existing use indicates GCC gets it right, but it would be a shame if we
lost coverage because a compiler implementation ignores the sign of zero
in initialisation.
> If there are no objections, I will check it tomorrow.
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?
Otherwise I wonder whether the test cases just ought to set the sign bit
of the expected negative part of the array at run time, via a constructor.
Maciej
More information about the Libc-alpha
mailing list