Chapter 5. Mathematics <math.h>

Table of Contents
5.1. Treatment of Error Conditions
5.2. Notes
5.3. Trigonometric Functions
5.4. Hyperbolic Functions
5.5. Exponential and Logarithmic Functions
5.6. Power Functions
5.7. Nearest Integer, Absolute Value and Remainder Functions

The header <math.h> declares several mathematical functions and defines one macro. The functions take double arguments and return double values.

The macro is defined as

HUGE_VAL

which expands to a positive double expression, not necessarily representable as a float.

5.1. Treatment of Error Conditions

The behavior of each of these functions is defined for all representable values of its input arguments. Each function shall execute as if it were a single operation, without generating any externally visible exceptions.

For all functions a domain error occurs if the input argument is outside the domain over which the mathematical function is defined. The description of each function lists any required domain errors: an implementation may define additional domain errors, provided that such errors are consistent with the mathematical definition of the function. On a domain error the function returns an implementation-defined value: the value of the macros EDOM is stored in errno.

Similarly a range error occurs if the result of the function cannot be represented as a double value. If the result overflows (the magnitude of the result is so large that it cannot be represented in an object of the specified type), the function returns the value of the macro HUGE_VAL with the same sign (except for the tan function) as the correct value of the function: the value of the macro ERANGE is stored in errno. If the result underflows (the magnitude of the result is so small that it cannot be represented in an object of the specified type), the function returns zero: whether the integer expression errno acquires the value of the macro ERANGE is implementation-defined.