Document: WG14 N1593
Submitter: Fred J. Tydeman (USA)
Submission Date: 2012-1-11
Subject: f(inf) is inf being a range error
Several of the functions in <math.h> that compute infinity for f(infinity) have the phrase (or something similar):
A range error occurs if the magnitude of x is too large.
Since infinity is 'too large', one might conclude that f(infinity) is a range error for those functions.
However, 7.12.1#5 has:
A floating result overflows if the magnitude of the mathematical result is finite but so large that the mathematical result cannot be represented without extraordinary roundoff error ...
The key word being 'finite'. So, one could conclude f(infinity) being infinity is not overflow (and therefore, not a range error).
To me, this appears to be a contradiction. I have encountered both kinds of implementations; some treat this case as a range error, and others that do not.
For both LIA and IEEE-754, f(infinity) being infinity is not considered an error.
I believe that the following changes to C11 would clear up this issue.
Change to: A range error occurs if the magnitude of finite x is too large.
Change to: A range error occurs if the magnitude of finite x is too large.
Change to: A range error occurs if the magnitude of finite x is too large.
Change to: A range error occurs if the magnitude of finite x is too large.
Change to: A range error occurs if the magnitude of finite x is too large.
Change to: A range error may occur for finite arguments.
Change to: A range error may occur for finite arguments.
Change to: A range error may occur for finite arguments.
Change to: A range error may occur for finite arguments.
Change to: A range error occurs if finite x is too large.
Change to: A range error occurs if finite x is too large.
Change to: A range error occurs if the magnitude of finite x is too large and may occur if the magnitude of x is too small.
Change to: A range error may occur for finite arguments.
Change to: A range error may occur for finite arguments.