acos, acosf, acosl

Header: <math.h>

1-6) Computes the principal value of the arc cosine of arg.

# Declarations

float acosf( float arg );

(since C99)

double acos( double arg );
long double acosl( long double arg );

(since C99)

_Decimal32 acosd32( _Decimal32 arg );

(since C23)

_Decimal64 acosd64( _Decimal64 arg );

(since C23)

_Decimal128 acosd128( _Decimal128 arg );

(since C23)

#define acos( arg )

(since C99)

# Parameters

# Return value

If no errors occur, the arc cosine of arg (arccos(arg)) in the range [0 ; π], is returned.

# Example

#include <errno.h>
#include <fenv.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
 
#ifndef __GNUC__
#pragma STDC FENV_ACCESS ON
#endif
 
int main(void)
{
    printf("acos(-1) = %f\n", acos(-1));
    printf("acos(0.0) = %f 2*acos(0.0) = %f\n", acos(0), 2 * acos(0));
    printf("acos(0.5) = %f 3*acos(0.5) = %f\n", acos(0.5), 3 * acos(0.5));
    printf("acos(1) = %f\n", acos(1));
 
    // error handling
    errno = 0; feclearexcept(FE_ALL_EXCEPT);
    printf("acos(1.1) = %f\n", acos(1.1));
    if (errno == EDOM)
        perror("    errno == EDOM");
    if (fetestexcept(FE_INVALID))
        puts("    FE_INVALID raised");
}

# See also