[Cfp-interest 3078] Re: text of the strto* and wcstodN functions

Jim Thomas jaswthomas at sbcglobal.net
Sat Apr 6 15:03:15 PDT 2024


The issues below are represented in Issue 19 in C26D.

> On Feb 20, 2024, at 8:22 AM, Vincent Lefevre <vincent at vinc17.net> wrote:
> 
> On 2024-02-19 09:10:29 -0800, Jim Thomas wrote:
>> The Description for the strtodN function says: "If all subject
>> sequences of hexadecimal form are correctly rounded, …”. I think in
>> context the meaning will be correctly understood as: for these
>> inputs the result delivered by the function is correctly rounded.
>> The Description of wcstodN has the same wording.
> 
> Well, this is poor wording. The following is based on N3149.
> 
> First, there are some issues in other parts of the text, including
> for strtod, strtof and strtold:
> 
> 7.24.1.5p4 says "If the subject sequence has the expected form
> for a floating-point number, the sequence of characters starting
> with the first digit or the decimal-point character [...]", but
> infinities are floating-point numbers.

> So, for instance, this
> does not make sense for "INF". I think that it should have said
> "finite number" instead of "floating-point number" (note that
> it is not a finite floating-point number before conversion, and
> due to overflow, it may become infinite).
> 
> There is the same issue in 7.24.1.6p4 for the strtodN functions.

Infinities are not floating-point numbers. See 5.2.5.3.3 #3 and #8. I think either “floating-point number” or “finite number” would be correct here. The latter seems more direct.

> 
> 7.24.1.6p5 starts with "If the subject sequence has the expected form
> for a decimal floating-point number", which does not make much sense
> as one may use both the decimal form and the hexadecimal form for
> decimal floating-point numbers. I suppose that it should say
> "If the subject sequence has the decimal form" like strtod.

> 
> 7.24.1.6p6 starts with "If the subject sequence has the expected form
> for a hexadecimal floating-point number". Same problem. I suppose that
> it should say "If the subject sequence has the hexadecimal form" like
> strtod.

Right. And there are other place where “a decimal floating-number” is used to mean a sequence in the decimal form, and likewise for hexadecimal. For example, 7.24.1.5 #4 says "if neither an exponent part nor a decimal-point character appears in a decimal floating-point number, or if a binary exponent part does not appear in a hexadecimal floating-point number”. We should find such uses and check that using “decimal form” and “hexadecimal form” would be ok. Also, it might be helpful to explicitly identify the forms where they are specified, e.g. in 7.24.1.5 #3:

…

— decimal form: a nonempty sequence of decimal digits optionally containing a decimal-point character, then an optional exponent part as defined in 6.4.4.3, excluding any digit separators (6.4.4.2);

— hexadecimal form: a 0x or 0X, then a nonempty sequence of hexadecimal digits optionally containing a decimal-point character, then an optional binary exponent part as defined in 6.4.4.3, excluding any digit separators;

> 
> "If all subject sequences of hexadecimal form are correctly rounded,
> M may be regarded as infinite." is hard to understand because this is
> not the usual use of "correctly rounded". I think that it should say
> "If the value resulting from the conversion is correctly rounded for
> all possible subject sequences of hexadecimal form, M may be regarded
> as infinite."
> 
> One may say "correctly rounded" for an operation or its result, but
> not for an input.

CFP is addressing this. See 

[Cfp-interest 3058] problematic use of correctly rounded  <https://mailman.oakapple.net/pipermail/cfp-interest/2024-March/003072.html>

- Jim Thomas
> 
> Ditto for the wcstodN functions (paragraphs 4 to 6).
> 
> -- 
> Vincent Lefèvre <vincent at vinc17.net> - Web: <https://www.vinc17.net/>
> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
> _______________________________________________
> 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/20240406/7c6f9b72/attachment.htm>


More information about the Cfp-interest mailing list