[Cfp-interest 3092] about C26 Issue 1

Jerome Coonen jcoonen at gmail.com
Mon Apr 8 22:04:27 PDT 2024


Fred reported this issue and Jim provided significant background. This
proposal supersedes a prior version. The task is to refine the exceptional
cases in gamma and log gamma. The topic expanded into the naming of the
exception.


Proposal 1 -- C sect 7.12.1 #3
Current:

Similarly, a pole error (also known as a singularity or infinitary) occurs
if and only if the mathematical function has an exact infinite result as
the finite input argument(s) are approached in the limit (for example,
log(0.0)). The description of each function lists any required pole errors;
an implementation may define additional pole errors, provided that such
errors are consistent with the mathematical definition of the function. On
a pole error, the function returns an implementation-defined value; if the
integer expression math_errhandling & MATH_ERRNO is nonzero, the integer
expression errno acquires the value ERANGE; if the integer expression
math_errhandling & MATH_ERREXCEPT is nonzero, the "divide-by-zero"
floating-point exception is raised.

Proposed:

Similarly, a divide-by-zero error occurs if and only if the function
returns an infinite value for finite arguments, where the mathematical
function has an infinite limit (for example, *log(0.0**)* = -∞). The
description of each function lists any required divide-by-zero errors; an
implementation may define additional divide-by-zero errors, provided that
such errors are consistent with the mathematical definition of the
function. On a divide-by-zero error, the function returns an
implementation-defined value; if the integer expression math_errhandling &
MATH_ERRNO is nonzero, the integer expression errno acquires the value
ERANGE; if the integer expression math_errhandling & MATH_ERREXCEPT is
nonzero, the "divide-by-zero" floating-point exception is raised.


Proposal 2 -- C sect 7.12.x, Change 25 instances
Current:

pole error

Proposed:

divide-by-zero error


Proposal 3 -- C sect 1.12.8.3 #2 on log gamma
Current:

A pole error may occur if x is a negative integer or zero.

Proposed:

A domain error or divide-by-zero error may occur if x is a negative integer
or zero.


Proposal 4 -- C sect 1.12.8.4 p#2 on tgamma
Current:

A domain error or a pole error may occur if x is a negative integer or zero.

Proposed:

A domain error or divide-by-zero error may occur if x is a negative integer
or zero.



DISCUSSION

Proposals 1 & 2 -- "Pole error" (perhaps inspired by a single mention in
sect. 9.2 of 60559) has several problems. It draws from the language of
singularities in complex analysis, which is not a prerequisite for using
real types in C. And "pole" is misleading. Not every singularity
encountered in the library functions is a pole (as in the given example
log(0), which is an essential singularity). It's far simpler to use the
legacy term "divide-by-zero" for what is going to be reported as a
"divide-by-zero" error on modern systems.

Proposals 3&4 -- The gamma function approaches ±inf on either side of the
negative integers, so tgamma must have a domain error at the negative
integers. The sign of the infinite result at zero is resolved by the sign
of zero on 60559 systems. Function lgamma is better behaved because it is
defined as the absolute value of the log of gamma. On 60559 systems, it has
a divide-by-zero error at the negative integers and never a domain error.

Proposal 1 -- The language of section 7.12.1 -- "...lists any required
divide-by-zero errors" -- is not consistent with the language later in
section 7 -- "A divide-by-zero error may occur..." If the error is
required, a stronger verb form is called for.
-Jerome Coonen
 650.996.4738
 jcoonen at gmail.com

>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20240408/c572e643/attachment.htm>


More information about the Cfp-interest mailing list