[Cfp-interest 3259] Re: Can nan() set errno?
Fred J. Tydeman
tydeman at tybor.com
Fri Sep 6 03:35:35 PDT 2024
On Thu, 29 Aug 2024 08:44:41 -0700 Jim Thomas wrote:
>
>I suggest the following response:
>
>As specified, the nan() function really is equivalent to the corresponding use of strtod(). The nan() function is not allowed to
>affect errno.
>
>7.5 #3 says:
>
> The value of errno may be set to nonzero by a library function call whether or not there is an error, provided the use of
>errno is not documented in the description of the function in this document.
>
>strtod() documents use of errno for overflow and underflow, which prohibits other use of errno, including for the case that is
>equivalent to the nan() function.
>
>The specification of <math.h> functions includes the general specification in 7.12. Subclause 7.12.2 #2 says
>
>For all functions, a domain error occurs if and only if an input argument is outside the domain over which the mathematical
>function is defined. The description of each function lists any required domain errors; an implementation may define
>additional domain errors, provided that such errors are consistent with the mathematical definition of the function.
>
>There are similar statements for range and pole errors. This specification would (in the absence of the equivalence to
>strtod) permit nan() to set errno but only in a way consistent with the meaning of the error. This qualification clearly
>excludes range errors (which pertain to numeric results being too large or small for the format) and pole errors. Since the
>meaning of the n-char-sequences is implementation-defined (see strtod 7.24.2.6 #5), one might be tempted to say some
>n-char-sequences are outside the domain of the function and define a domain error, but that is not an intended
>interpretation and the equivalence to strtod prohibits it.
I am fine with that response.
---
Fred J. Tydeman Tydeman Consulting
tydeman at tybor.com Testing, numerics, programming
+1 (702) 608-6093 Vice-chair of INCITS/C (ANSI "C")
Sample C17+FPCE tests: http://www.tybor.com
Savers sleep well, investors eat well, spenders work forever.
More information about the Cfp-interest
mailing list