The SQL ACOS
function calculates the arc cosine of a numeric expression that evaluates a float value between -1 and 1.
In math, the arccosine(x)
is defined as the inverse cosine(x)
when -1≤x≤1
.
Syntax
The following shows the syntax of the ACOS
function.
ACOS(numeric_expression)
Code language: SQL (Structured Query Language) (sql)
Argument
The ACOS
function accepts a numeric_expression
that evaluates to a float value in the range -1 and 1.
Return Type
The ACOS
function returns a floating-point number in radians.
Examples
The following example returns the arc cosine of 0.5
SELECT ACOS(0.5);
Code language: SQL (Structured Query Language) (sql)
acos
-----------------
1.0471975511966
(1 row)
Code language: SQL (Structured Query Language) (sql)
To see the degrees value, you use the DEGREES
function.
SELECT DEGREES(ACOS(0.5));
Code language: SQL (Structured Query Language) (sql)
degrees
---------
60
(1 row)
Code language: SQL (Structured Query Language) (sql)
Most database systems support the ACOS
function with the same behavior.
Was this tutorial helpful ?