Oracle - ACOS() Function
The Oracle (PL/SQL) ACOS() function returns arc cosine of a value. The returned value will be in the range 0 through 𝜋. In special cases it returns the following:
- If the number is not within the range of -1 to 1, then an error is returned.
Note: ACOS() is the inverse of COS().
Syntax
ACOS(x)
Parameters
x |
Required. Specify the value. |
Return Value
Returns the arc cosine of the value.
Example 1:
The example below shows the usage of ACOS() function.
ACOS(0.2) Result: 1.36943840600456582777619613942212803186 ACOS(0.8) Result: .643501108793284386802809228717322638059 ACOS(1) Result: 0 ACOS(-1) Result: 3.1415926535897932384626433832795028842 ACOS(0) Result: 1.5707963267948966192313216916397514421 ACOS(-0.2) Result: 1.77215424758522741068644724385737485234
Example 2:
Consider a database table called Sample with the following records:
Data | x |
---|---|
Data 1 | -1 |
Data 2 | -0.5 |
Data 3 | 0 |
Data 4 | 0.5 |
Data 5 | 1 |
The statement given below can be used to calculate the arc cosine of records of column x.
SELECT Sample.*, ACOS(x) AS ACOS_Value FROM Sample;
This will produce the result as shown below:
Data | x | ACOS_Value |
---|---|---|
Data 1 | -1 | 3.1415926535897932384626433832795028842 |
Data 2 | -0.5 | 2.09439510239319549230842892218633525615 |
Data 3 | 0 | 1.5707963267948966192313216916397514421 |
Data 4 | 0.5 | 1.04719755119659774615421446109316762805 |
Data 5 | 1 | 0 |
❮ Oracle Functions