[Cfp-interest] strtodN subject sequence with minus sign

Fred J. Tydeman tydeman at tybor.com
Sun Aug 26 21:36:11 PDT 2012


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.

>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.

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)".

---
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.



More information about the Cfp-interest mailing list