...
Anchor | ||||
---|---|---|---|---|
|
lgamma(x), tgamma(x)
The "too large" and "too small" conditions for a range error in the gamma functions are vague enough to make it very difficult to catch all possible range errors simply by looking at the inputMathematically speaking, the domain of both lgamma()
and tgamma()
is the set of real numbers excepting the non-positive integers. However, since both functions often yield numbers of very large magnitude or very small magnitude, the set of inputs that do not cause a range error is not only more limited, but poorly defined. For instance, tgamma(-90.5)
is close enough to 0 that it causes an underflow error on 64-bit IEEE double
implementations.
Noncompliant Code Example
This noncompliant code example attempts to prevent domain and range errors, but a range error occurs nonethelessdoes not prevent range errors. The result is often an underflow error.
Code Block | ||
---|---|---|
| ||
float x = -90.5; if ((x == 0) || (x < 0 && x == nearbyint(x))) { /* handle error */ } float f = tgamma(x); |
...