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

Vincent Lefevre vincent at vinc17.net
Sat Apr 6 19:46:35 PDT 2024


On 2024-04-06 15:03:15 -0700, Jim Thomas wrote:
> 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.

OK, that's a confusion with IEEE 754, where infinities are
floating-point numbers. But the use of "floating-point number" is
incorrect here, because in 5.2.5.3.3, a floating-point number is
restricted to be written in base b with a precision p (not more).
For strtodN, this does not make sense.

But also, note that the standard sometimes says "finite floating-point
number".

The term "floating-point number" is also used for ceil and floor
(James Kuyper had already pointed this issue in comp.std.c in
August 2021).

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