Everything
7.4.8 <mathf.h>

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.

Type

Definition Name

Description

Constant

(macro)

EDOM

Indicates the value to be set in errno if the value of a parameter input to a function is outside the range of values defined in the function.

ERANGE

Indicates the value to be set in errno if the result of a function cannot be represented as a float type value, or if an overflow or an underflow occurs.

HUGE_VALF

HUGE_VAL

HUGE_VALL

Indicates the value for the function return value if the result of a function overflows.

Function

acosf

Calculates the arc cosine of a floating-point number.

asinf

Calculates the arc sine of a floating-point number.

atanf

Calculates the arc tangent of a floating-point number.

atan2f

Calculates the arc tangent of the result of a division of two floating-point numbers.

cosf

Calculates the cosine of a floating-point radian value.

sinf

Calculates the sine of a floating-point radian value.

tanf

Calculates the tangent of a floating-point radian value.

coshf

Calculates the hyperbolic cosine of a floating-point number.

sinhf

Calculates the hyperbolic sine of a floating-point number.

tanhf

Calculates the hyperbolic tangent of a floating-point number.

expf

Calculates the exponential function of a floating-point number.

frexpf

Breaks a floating-point number into a [0.5, 1.0) value and a power of 2.

ldexpf

Multiplies a floating-point number by a power of 2.

logf

Calculates the natural logarithm of a floating-point number.

log10f

Calculates the base-ten logarithm of a floating-point number.

modff

Breaks a floating-point number into integral and fractional parts.

powf

Calculates a power of a floating-point number.

sqrtf

Calculates the positive square root of a floating-point number.

ceilf

Calculates the smallest integral value not less than or equal to the given floating-point number.

fabsf

Calculates the absolute value of a floating-point number.

floorf

Calculates the largest integral value not greater than or equal to the given floating-point number.

fmodf

Calculates the remainder of a division of two floating-point numbers.

 

Operation in the event of an error is described below.

(1)

Domain error

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.

(2)

Range error

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.

Notes 1.

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.

[Format]

             .
             .
             .
         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.

Notes 2.

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

Item

Compiler 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

Not specified

Whether a range error occurs if the second argument in the fmodf function is 0

A range error occurs.