Performs various mathematical operations.
<mathf.h> declares mathematical functions and defines macros in single-precision format. The mathematical functions and macros used here do not follow the ANSI specifications. Each function receives float-type arguments and returns a float-type value.
The following constants (macros) are all implementation-defined.
Operation in the event of an error is described below.
A domain error occurs if the value of a parameter input to a function is outside the domain over which the mathematical function is defined. In this case, the value of EDOM is set in errno. The function return value in implementation-defined.
A range error occurs if the result of a function cannot be represented as a float type value. In this case, the value of ERANGE is set in errno. If the result overflows, the function returns the value of HUGE_VALF, with the same sign as the correct value of the function. If the result underflows, 0 is returned as the return value.
If there is a possibility of a domain error resulting from a <mathf.h> function call, it is dangerous to use the resultant value directly. The value of errno should always be checked before using the result in such cases. |
.
.
.
1 x=asinf(a);
2 if (errno==EDOM)
3 printf ("error\n");
4 else
5 printf ("result is : %f\n",x);
.
.
.
In line 1, the arc sine value is computed using the asinf function. If the value of argument a is outside the asinf function domain [–1.0, 1.0], the EDOM value is set in errno. Line 2 determines whether a domain error has occurred. If a domain error has occurred, error is output in line 3. If there is no domain error, the arc sine value is output in line 5.
Whether or not a range error occurs depends on the internal representation format of floating-point types determined by the compiler. For example, if an internal representation format that allows an infinity to be represented as a value is used, <mathf.h> library functions can be implemented without causing range errors. |
Implementation-Defined Specifications
Value returned by a mathematical function if an input argument is out of the range |
A not-a-number is returned. For details on the format of not-a-numbers, refer to section 4.1.6 (5) Floating-Point Number Specifications. |
Whether errno is set to the value of macro ERANGE if an underflow error occurs in a mathematical function |
|
Whether a range error occurs if the second argument in the fmodf function is 0 |