Namespaces
Variants
Views
Actions

std::acos

From cppreference.com
< cpp‎ | numeric‎ | math
 
 
 
Common mathematical functions
Functions
Basic operations
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)(C++11)(C++11)
Exponential functions
(C++11)
(C++11)
(C++11)
(C++11)
Power functions
(C++11)
(C++11)
Trigonometric and hyperbolic functions
(C++11)
(C++11)
(C++11)
Error and gamma functions
(C++11)
(C++11)
(C++11)
(C++11)
Nearest integer floating point operations
(C++11)(C++11)(C++11)
(C++11)
(C++11)
(C++11)(C++11)(C++11)
Floating point manipulation functions
(C++11)(C++11)
(C++11)
(C++11)
(C++11)(C++11)
(C++11)
Classification/Comparison
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
Macro constants
(C++11)(C++11)(C++11)(C++11)(C++11)
 
Defined in header <cmath>
float       acos( float arg );
double      acos( double arg );
long double acos( long double arg );
double      acos( Integral arg );
(since C++11)

Computes arc cosine of arg.

Contents

[edit] Parameters

arg - value of a floating-point or Integral type

[edit] Return value

Arc cosine of arg in radians in the range of [0; π] radians.

Domain error occurs if arg is outside the range [-1.0; 1.0]. NaN is returned in that case and FE_INVALID is raised.

std::acos(1) returns +0.

[edit] Example

#include <cmath>
#include <iostream>
 
int main()
{
    std::cout << "The number pi is " << std::acos(-1) << '\n';
}

Output:

The number pi is 3.14159

[edit] See also

computes arc sine (arcsin(x))
(function) [edit]
computes arc tangent (arctan(x))
(function) [edit]
arc tangent, using signs to determine quadrants
(function) [edit]
computes cosine (cos(x))
(function) [edit]
computes arc cosine of a complex number (arccos(z))
(function template) [edit]
applies the function std::acos to each element of valarray
(function template) [edit]