[Cfp-interest 3007] text of the strto* and wcstodN functions

Vincent Lefevre vincent at vinc17.net
Tue Feb 20 08:22:58 PST 2024


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.

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.

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

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)


More information about the Cfp-interest mailing list