acos, acosf
 Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

# acos, acosf

Visual Studio .NET 2003

Calculates the arccosine.

```double acos(
double x
);
float acos(
float x
);   // C++ only
long double acos(
long double x
);   // C++ only
float acosf(
float x
);
```

#### Parameter

x
Value between –1 and 1 whose arccosine is to be calculated.

#### Return Value

The acos function returns the arccosine of x in the range 0 to &pi; radians.

If x is less than –1 or greater than 1, acos returns an indefinite by default.

Input SEH Exception Matherr Exception
± &infin; INVALID _DOMAIN
± QNAN,IND none _DOMAIN
|x|>1 INVALID _DOMAIN

#### Remarks

C++ allows overloading, so you can call overloads of acos. In a C program, acos always takes and returns a double.

#### Requirements

acos, acosf <math.h> <errno.h> ANSI, Win 98, Win Me, Win NT, Win 2000, Win XP

For additional compatibility information, see Compatibility in the Introduction.

Libraries

All versions of the C run-time libraries.

#### Example

This program prompts for a value in the range -1 to 1. Input values outside this range will produce _DOMAIN error messages. If a valid value is entered, the program prints the arcsine and the arccosine of that value.

```// crt_asincos.c
// arguments: 0
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>

int main( int ac, char* av[] )
{
double x, y;

if (ac != 2) {
fprintf(stderr, "Usage: %s <number between -1 and 1>\n", av[0]);
return 1;
}
sscanf( av[1], "%lf", &x );
y = asin( x );
printf( "Arcsine of %f = %f\n", x, y );
y = acos( x );
printf( "Arccosine of %f = %f\n", x, y );
}
```

#### Output

```Arcsine of 0.000000 = 0.000000
Arccosine of 0.000000 = 1.570796
```