[Cfp-interest 1852] Re: Negative zero

Damian McGuckin damianm at esi.com.au
Sat Nov 21 16:30:53 PST 2020


On Sat, 21 Nov 2020, Jim Thomas wrote:

> In a recent post to STDS-754, Vincent Lef?vre wrote:
>
>       I think that the terminology should be:
>        * negative: equivalent to "less than zero", i.e. "< 0";
>        * negative sign: can be used for any FP number; -0 has a
>          negative sign, but NaN does not have a sign;
>        * negative sign bit: can be used for any FP datum.
> 
> Do we agree with this interpretation of ?negative?? 
> 
> (I do, except for the last item. Do qNaN and sNaN data in an extended format
> necessarily have a sign bit?

None of NaN, qNaN and sNan have a sign. However, they do have a sign bit. 
Why should that be any different for extended format (even though IEC60559
does not specify what it is)?

> A sign bit pertains to encoding and 754 doesn?t specify an encoding for 
> extended formats. I think this is a 754 issue.

Yes. So, C23 should not try and resolve it. But does that mean we need to 
explicitly say that it is undefined. Out of curiosity, how many chipsets 
in use today still use an extended IEC60559 format?

> Does C require opposite-signed zeros to compare equal? Does Annex F say 
> this explicitly? Annex F says it implicitly by reference to IEC 60559, 
> so it should be editorial to say it explicitly in Annex F.

Sounds wise although I never know when to editorialize and when to not.

> We might want to add a (foot)note to point out that negative zero and NaNs
> with a negative sign bit are not negative values.

Yes. Why not within the text so it is glaringly obvious?

> Have we been careful enough about distinguishing the sign of a value and 
> the bit sign of the representation? For example, 7.12.3.7 says
> 
> The signbit macro returns a nonzero value if and only if the sign of its
> argument value is negative.

As MikeC correctly notes, the signbit() macro is testing the signbit of 
the encoding, not its negativity.

But JimT's original question was whether we had been careful enough to 
distinguish between the sign of a value and the sign bit within Annex F. 
Asking ourselves is probably counterproductive as we are all too close to 
it. We should each probably ask a few of our colleagues to get a better 
idea that this had been achieved.

Regards - Damian

Pacific Engineering Systems International, 277-279 Broadway, Glebe NSW 2037
Ph:+61-2-8571-0847 .. Fx:+61-2-9692-9623 | unsolicited email not wanted here
Views & opinions here are mine and not those of any past or present employer


More information about the Cfp-interest mailing list