[Cfp-interest 1532] Re: Range errors

Jim Thomas jaswthomas at sbcglobal.net
Fri Mar 6 11:49:35 PST 2020


> On Feb 19, 2020, at 11:45 AM, Fred J. Tydeman <tydeman at tybor.com> wrote:
> 
> Yet another attempt as an attachment.
> Please comment soon so I can try to make the next WG14 mailing deadline.
> 
> 
> 
> ---
> Fred J. Tydeman        Tydeman Consulting
> tydeman at tybor.com <mailto:tydeman at tybor.com>      Testing, numerics, programming
> +1 (702) 608-6093      Vice-chair of PL22.11 (ANSI "C")
> Sample C99+FPCE tests: http://www.tybor.com <http://www.tybor.com/>
> Savers sleep well, investors eat well, spenders work forever.
> 
> 
> Submitter:Fred Tydeman
> Submission Date: 2020-02-??
> Document: WG14 Nxxxx
> Reference Documents:
> 
> Summary
> 
> The standard has a few incorrect, missing, or ambiguous statements about range errors in some of the math functions.
> 
> Does "too large" mean close to +infinity or +/-infinity?
> 
> Does "too small" mean close to -infinity or +/-zero?
> 
> 
I think there are two problems. As you say, there are a few incorrect, missing, or ambiguous statements. But also there’s the problem of too casual reading of statements that are correct given common mathematical terminology. We’re trying to address both of these problems by fixing the former and by clarifying the specification to be less subject to misreading. I’m not suggesting this be stated in the paper, but consider adding “Implementers have interpreted these terms differently” (assuming of course it’s true). 
> It appears that "magnitude" has no formal definition.
> 
> 

Is there any evidence that “magnitude” has been misunderstood? If not, omit the statement about magnitude.

 
> 
> 
> Some implementations incorrectly treat f(infinity) as a range error based upon the text: A range error occurs if [the magnitude of] x is too large. While this is covered by 7.12.1#5 about overflows, the CFP group believes it is better to be explicit in each math function where it matters.
> 
> Possible Technical Corrigendum:
> 
> Sizes of integer types <limits.h>
> Change 5.2.4.2.1#1 to give magnitude a definition
> 
> ... magnitude (absolute value) ...
> to:
> ... magnitude (absolute value) …
I don’t think this is needed. What problem is it fixing? Also, just italicizing it doesn’t provide a definition. Parenthetical remarks should not be normative. And, there’s no definition of absolute value in the standard.
> Treatment of error conditions
> Change 7.12.1#5
> 
> ... overflows if the magnitude ...
> to:
> ... overflows if the magnitude (absolute value) ...
> Treatment of error conditions
> Change 7.12.1#6
> 
> ... underflows if the magnitude ...
> to:
> ... underflows if the magnitude (absolute value) …

> Add to 7.12.4.2#2
> 
> A range error occurs if nonzero x is too close to zero.
> The atan functions
> Add to 7.12.4.3#2
> 
> A range error occurs if nonzero x is too close to zero.
> The atan2 functions
> Add to 7.12.4.4#2
> 
> A range error occurs if x is positive and nonzero y/x is too close to zero.
> The sin functions
> Add to 7.12.4.6#2
> 
> A range error occurs if nonzero x is too close to zero.
> The tan functions
> Add to 7.12.4.7#2
> 
> A range error occurs if nonzero x is too close to zero.
> The asinpi functions
> Change 7.12.4.9#2
> 
> A range error occurs if the magnitude of nonzero x is too small.
> to:
> A range error occurs if the magnitude of nonzero x is too smallclose to zero.
> The atanpi functions
> Change 7.12.4.10#2
> 
> A range error occurs if the magnitude of nonzero x is too small.
> to:
> A range error occurs if the magnitude of nonzero x is too smallclose to zero.
> The atan2pi functions
> Change 7.12.4.11#2
> 
> A range error occurs if x is positive and the magnitude of nonzero y/x is too small.
> to:
> A range error occurs if x is positive and the magnitude of nonzero y/x is too small close to zero.
> The sinpi functions
> Add to 7.12.4.13#2
> 
> A range error occurs if nonzero x is too close to zero.
> The tanpi functions
> Add to 7.12.4.14#2
> 
> A range error occurs if nonzero x is too close to zero.
> The asinh functions
> Add to 7.12.5.2#2
> 
> A range error occurs if nonzero x is too close to zero.
> The atanh functions
> Add to 7.12.5.3#2
> 
> A range error occurs if nonzero x is too close to zero.
> The cosh functions
> Change 7.12.5.4#2 from
> 
> A range error occurs if the magnitude of x is too large.
> to
> 
> A range error occurs if the magnitude of finite x is too large.
> The sinh functions
> Change 7.12.5.5#2 from
> 
> A range error occurs if the magnitude of x is too large.
> to
> 
> A range error occurs if the magnitude of finite x is too large or if nonzero x is too close to zero.
> The tanh functions
> Add to 7.12.5.6#2
> 
> A range error occurs if nonzero x is too close to zero.
> The exp functions
> Change 7.12.6.1#2 from
> 
> A range error occurs if the magnitude of x is too large.
> to
> 
> A range error occurs if the magnitude of finite x is too large.
> The exp10 functions
> Change 7.12.6.2#2 from
> 
> A range error occurs if the magnitude of x is too large.
> to
> 
> A range error occurs if the magnitude of finite x is too large.
> The exp10m1 functions
> Change 7.12.6.3#2 from
> 
> A range error occurs if finite x is too large or if the magnitude of nonzero x is too small.
> to
> 
> A range error occurs if positive finite x is too large or if the magnitude of nonzero x is toosmallclose to zero.
> The exp2 functions
> Change 7.12.6.4#2 from
> 
> A range error occurs if the magnitude of x is too large.
> to
> 
> A range error occurs if the magnitude of finite x is too large.
> The exp2m1 functions
> Change 7.12.6.5#2 from
> 
> A range error occurs if the magnitude of x is too large or if the magnitude of nonzero x is too small.
> to
> 
> A range error occurs if the magnitude of positive finite x is too large or if the magnitude ofnonzero x is too smallclose to zero.
> The expm1 functions
> Change 7.12.6.6#2 from
> 
> A range error occurs if positive x is too large.252)
> to
> 
> A range error occurs if positive finite x is too large or if nonzero x is too close to zero.252)
> The ldexp functions
> Change 7.12.6.9#2 from
> 
> A range error may occur.
> to
> 
> A range error may occuroccurs for some finite x, depending on p.
> The log10p1 function
> Change 7.12.6.13#2
> 
> A range error occurs if the magnitude of nonzero x is too small.
> to:
> A range error occurs if the magnitude nonzero x is too smallclose to zero.
> The log1p and logp1 functions
> Add to 7.12.6.14#2
> 
> A range error occurs if nonzero x is too close to zero.
> The log2p1 functions
> Add to 7.12.6.16#2
> 
> A range error occurs if nonzero x is too close to zero.
> The scalbn and scalbln functions
> Change 7.12.6.19#2 from
> 
> A range error may occur.
> to
> 
> A range error may occur occurs for some finite x, depending on n.
> The compoundn functions
> Change 7.12.7.2#2 from
> 
> A range error may occur if n is too large, depending on x.
> to
> 
> A range error may occuroccurs if positive finite x n is too large or if negative x is too near -1, depending on nx.
I think it should be

	• A range error occurs if positive finite x is too large or if x is too near but not equal to -1, depending on n.

> The hypot functions
> Change 7.12.7.4#2 from
> 
> A range error may occur.
> to
> 
> A range error may occuroccurs for some finite arguments.
> The pow functions
> Change 7.12.7.5#2 from
> 
> A range error may occur.
> to
> 
> A range error may occurocurs if the magnitude of nonzero finite x is too large or too near zero, depending on y.
> The pown functions
> Change 7.12.7.6#2 from
> 
> A range error may occur.
> to
> 
> A range error may occuroccurs if the magnitude of nonzero finite x is too large or too near zero, depending on n.
> The powr functions
> Change 7.12.7.7#2 from
> 
> A range error may occur.
> to
> 
> A range error may occuroccurs if positive nonzero finite x is too large or too near zero, depending on y.
> The rootn functions
> Change 7.12.7.8#2 from
> 
> A range error may occur if n is -1.
> to
> 
> A range error may occuroccurs if the magnitude of nonzero finite x is too large or too near zero and if n is -1.
Consider

	• A range error occurs if n is -1 and the magnitude of nonzero finite x is too large or too near zero.

> The erf functions
> Add to 7.12.8.1#2
> 
> A range error occurs if nonzero x is too close to zero.
> The erfc functions
> Change 7.12.8.2#2
> 
> A range error occurs if positive x is too large.
> to:
> 
> A range error occurs if positive finite x is too large.
> The lgamma functions
> Change 7.12.8.3#2
> 
> A range error occurs if positive x is too large.
> to:
> 
> A range error occurs if positive finite x is too large.
> The tgamma functions
> Change 7.12.8.4#2
> 
> A range error occurs if the magnitude of x is too large and may occur if the magnitude of x is too small.
> to:
> 
> A range error occurs for some negative finite x, and if the magnitude ofpositive finite x is too large, and may occur if the magnitude of nonzero x is too smallclose to zero.
I believe the following would be more consistent with other wording:

	• A range error occurs for some negative finite x, and if positive finite x is too large or nonzero x is too close to zero.

> The fmod functions
> Add to 7.12.10.1#2
> 
> A range error occurs if x is finite, both x and y are nonzero, and either is too close to zero.
> The remainder functions
> Add to 7.12.10.2#2
> 
> A range error occurs if x is finite, both x and y are nonzero, and either is too close to zero.
> The fdim functions
> Change 7.12.12.1#2
> 
> A range error may occur.
> to:
> 
> A range error may occuroccurs if positive finite x-y is too large or too close to zero.
> The fma functions
> Change 7.12.13.1#2
> 
> A range error may occur.
> to:
> 
> A range error may occuroccurs for some finite arguments.
> _______________________________________________
> Cfp-interest mailing list
> Cfp-interest at oakapple.net <mailto:Cfp-interest at oakapple.net>
> http://mailman.oakapple.net/mailman/listinfo/cfp-interest <http://mailman.oakapple.net/mailman/listinfo/cfp-interest>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20200306/c3bee57e/attachment-0003.html 


More information about the Cfp-interest mailing list