[Cfp-interest] llogb(1.)

Jim Thomas jaswthomas at sbcglobal.net
Mon Aug 27 10:04:04 PDT 2018


Regarding integer formats, C 6.2.6.2 says

If the implementation supports negative zeros, they shall be generated only by: 
— the &, |, ^, ~, <<, and >> operators with operands that produce such a value; 
— the+,- , *, /, and % operators where one operand is a negative zero and the result is zero; 
— compound assignment operators based on the above cases. 
It is unspecified whether these cases actually generate a negative zero or a normal zero, and whether a negative zero becomes a normal zero when stored in an object.

I think this is consistent with not interpreting the sign of zero.

And it implies that specification like llogb(1) = 0 doesn’t allow a negative zero to be returned.

- Jim Thomas

> On Aug 23, 2018, at 10:39 AM, Stephen Canon <scanon at apple.com> wrote:
> 
> C doesn’t interpret the sign of zero in integer formats, right? Both encodings are just “zero”. I’m not sure there’s actually a distinction to be made here.
> 
>> On Aug 23, 2018, at 12:49 PM, Jim Thomas <jaswthomas at sbcglobal.net> wrote:
>> 
>> Hmm. Is there any other place cfp specifies the sign of a zero in integer format?
>> 
>> 754 says "logB(1) is +0”. This is in a context that applies to logB functions that return in floating-point or integer formats. I’m guessing that the sign in +0 is not intended to apply to logB functions that return in integer format. I don’t believe there’s any other place 754 specifies the sign of a zero in integer format. We can ask the 754 committee.
>> 
>> - Jim Thomas
>> 
>>> On Aug 22, 2018, at 7:57 PM, Fred J. Tydeman <tydeman at tybor.com> wrote:
>>> 
>>> On Tue, 21 Aug 2018 15:09:37 -0700 Jim Thomas wrote:
>>>> 
>>>> llogb and ilogb return in integer format, so we don't need to say anything about the sign of a zero result for them.
>>> 
>>> That is true for 2's complement, but not for 1's complement or sign-magnitude.
>>> 
>>> 
>>> 
>>> ---
>>> Fred J. Tydeman        Tydeman Consulting
>>> tydeman at tybor.com      Testing, numerics, programming
>>> +1 (702) 608-6093      Vice-chair of PL22.11 (ANSI "C")
>>> Sample C99+FPCE tests: http://www.tybor.com
>>> Savers sleep well, investors eat well, spenders work forever.
>> 
>> 
>> _______________________________________________
>> Cfp-interest mailing list
>> Cfp-interest at oakapple.net
>> http://mailman.oakapple.net/mailman/listinfo/cfp-interest
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20180827/7494d54b/attachment.html 


More information about the Cfp-interest mailing list