ACOS
Description
Returns the arc cosine of x
, or NULL
if x
is not in the range -1
to 1
.
Syntax
ACOS(<x>)
Parameters
Parameter | Description |
---|---|
<x> | The value for which the arc cosine is to be calculated |
Return Value
The arc cosine value of parameter x
, expressed in radians.
Special Cases
- When
x
equals 1, returns 0 - When
x
equals 0, returns π/2 - When
x
equals -1, returns π - When
x
is not in the range [-1, 1], returnsNULL
- When
x
is NaN, returns NaN - When
x
is positive or negative infinity, returnsNULL
- When
x
is NULL, returns NULL
Examples
select acos(1);
+-----------+
| acos(1.0) |
+-----------+
| 0 |
+-----------+
select acos(0);
+--------------------+
| acos(0.0) |
+--------------------+
| 1.5707963267948966 |
+--------------------+
select acos(-1);
+--------------------+
| acos(-1.0) |
+--------------------+
| 3.141592653589793 |
+--------------------+
select acos(-2);
+------------+
| acos(-2.0) |
+------------+
| NULL |
+------------+
select acos(1.0000001);
+-----------------+
| acos(1.0000001) |
+-----------------+
| NULL |
+-----------------+
select acos(cast('nan' as double));
+---------------------------+
| acos(cast('nan' AS DOUBLE)) |
+---------------------------+
| NaN |
+---------------------------+
select acos(cast('inf' as double));
+---------------------------+
| acos(cast('inf' AS DOUBLE)) |
+---------------------------+
| NULL |
+---------------------------+