[Cfp-interest] strtodN subject sequence with minus sign
Rajan Bhakta
rbhakta at ca.ibm.com
Tue Aug 28 10:11:01 PDT 2012
Re the last point, I prefer adding the words as well for clarity.
Regards,
Rajan Bhakta
z/OS XL C/C++ Compiler Technical Architect
ISO C Standards Representative for Canada
C Compiler Development
Contact: rbhakta at ca.ibm.com, Rajan Bhakta/Toronto/IBM
Telephone: (905) 413-3995
From:
Jim Thomas <jaswthomas at sbcglobal.net>
To:
"Fred J. Tydeman" <tydeman at tybor.com>
Cc:
CFP <cfp-interest at ucbtest.org>
Date:
08/27/2012 07:16 PM
Subject:
Re: [Cfp-interest] strtodN subject sequence with minus sign
Sent by:
cfp-interest-bounces at oakapple.net
On Aug 26, 2012, at 9:36 PM, Fred J. Tydeman wrote:
> On Tue, 21 Aug 2012 11:36:20 -0700 Jim Thomas wrote:
>>
>>>>
>>>> 11.6 strtod32, strtod64, and strtod128 functions <stdlib.h>
>>>> PDF page 31, item [4]:
>>>> Add at the end of:
>>>> "If the subject sequence begins with a minus sign, the sequence is
>>>> interpreted as negated."
>>>> (before rounding).
>>>
>>> It says the sequence is interpreted as negated, not that the result of
>> rounding the unnegated sequence is negated. So no change needed
>
> C11 has a footnote on negated. That footnote is:
>
> 292) It is unspecified whether a minus-signed sequence is converted
> to a negative number directly or by negating the value resulting from
> converting the corresponding unsigned sequence (see F.5); the two
> methods may yield different results if rounding is toward positive or
> negative infinity. In either case, the functions honor the sign of
> zero if floating-point arithmetic supports signed zeros.
>
> That makes it clear the "interpreted as negated" phrase has two
meanings.
I believe the words give an implementation license to mis-round in this
particular way. This doesn't really seem necessary since C11 without Annex
F doesn't require correct rounding for strtod functions anyway. See below.
>
>> In the Aug teleconference, David asked would "interpreted as negative"
be
>> better? I think it might be a little clearer. However, the current
words (
>> negated) match what's in C11 for the generic strtod family. I'm
inclined
>> against making strtodN differ from strtod on this point. Does anyone
think a
>> C11 defect report is in order?
>
> C11 F.5 has:
>
> Functions such as strtod that convert character sequences to floating
> types honor the rounding direction. Hence, if the rounding direction
> might be upward or downward, the implementation cannot convert a
> minus-signed sequence by negating the converted unsigned sequence.
This says that honoring the directed rounding modes requires negating
before rounding. And we require the decimal strto functions to round
correctly.
>
> Since strtod32/64/128 are for IEEE-754 DFP types, F.5 is in effect and
> I believe we could differ some from strtof/d/ld.
>
> I see no defect in C11.
>
> I prefer adding "(before rounding)".
I still don't think it's strictly necessary, but wouldn't object to adding
it.
-Jim
>
> ---
> Fred J. Tydeman Tydeman Consulting
> tydeman at tybor.com Testing, numerics, programming
> +1 (775) 287-5904 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
_______________________________________________
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/20120828/31650a7e/attachment-0001.html
More information about the Cfp-interest
mailing list