[cfp-interest 3432] Re: sign bit of a NaN

Jim Thomas jaswthomas at sbcglobal.net
Sun Apr 13 20:37:35 PDT 2025


The cproj case is interesting because the sign in a non-NAN result depends on the sign bit of a NaN in the input. Thus the sign in the result is unspecified in this case. This could be avoided by requiring the now unspecified sign in the cproj result to be positive in this case. But I don’t think that would be worth breaking existing implementations or the performance hit. I think it would be better to leave the sign unspecified: a natural consequence following from the bit-level definition of copysign.

- Jim Thomas

> On Mar 28, 2025, at 7:18 PM, Damian McGuckin <damianm at esi.com.au> wrote:
> 
> 
> In looking at somebodies example, it was noticed that
> 
> 	const double nan = 0.0/0.0
> 
> delivers
> 
> 	-nan ... with gcc 11
> 	+nan ,,, with clang 17
> 
> I know that the sign is irrelevant on a NaN but with something like cproj() whose sign of its imaginary component does depend on this,
> one might get the wrong answer (alough not one which will compare as
> different).
> 
> What should the above yield or is there not an answer to that question?
> 
> Note that
> 
> 	const double inf = 1.0/0.0
> 
> yields +INFINITY with both compilers.
> 
> Thanks - Damian
> _______________________________________________
> cfp-interest mailing list
> cfp-interest at oakapple.net
> http://mailman.oakapple.net/mailman/listinfo/cfp-interest




More information about the cfp-interest mailing list