Many of the functions listed in this chapter are defined mathematically
over a domain that is only a subset of real numbers. For example, the
acos function is defined over the domain between -1 and
1. If you pass an argument to one of these functions that is
outside the domain over which it is defined, the function sets
errno to EDOM to indicate a domain error. On
machines that support IEEE 754 floating point, functions reporting
error EDOM also return a NaN.
Some of these functions are defined mathematically to result in a complex value over parts of their domains. The most familiar example of this is taking the square root of a negative number. The functions in this chapter take only real arguments and return only real values; therefore, if the value ought to be nonreal, this is treated as a domain error.
A related problem is that the mathematical result of a function may not
be representable as a floating point number. If magnitude of the
correct result is too large to be represented, the function sets
errno to ERANGE to indicate a range error, and
returns a particular very large value (named by the macro
HUGE_VAL) or its negation (- HUGE_VAL).
If the magnitude of the result is too small, a value of zero is returned
instead. In this case, errno might or might not be
set to ERANGE.
The only completely reliable way to check for domain and range errors is
to set errno to 0 before you call the mathematical function
and test errno afterward. As a consequence of this use of
errno, use of the mathematical functions is not reentrant if you
check for errors.
None of the mathematical functions ever generates signals as a result of
domain or range errors. In particular, this means that you won't see
SIGFPE signals generated within these functions. (See section Signal Handling, for more information about signals.)
The value of this macro is used as the return value from various
mathematical double returning functions in overflow situations.
HUGE_VAL macro except that it is
used by functions returning float values.
This macro is a GNU extension.
HUGE_VAL macro except that it is
used by functions returning long double values. The value is
only different from HUGE_VAL if the architecture really supports
long double values.
This macro is a GNU extension.
For more information about floating-point representations and limits,
see section Floating Point Parameters. In particular, the macro
DBL_MAX might be more appropriate than HUGE_VAL for many
uses other than testing for an error in a mathematical function.
Go to the first, previous, next, last section, table of contents.