Oracle ACOS() Function
Oracle ACOS()
is a built-in function that returns the arccosine of a given number.
Oracle ACOS()
syntax
Here is the syntax for the Oracle ACOS()
function:
ACOS(num)
Parameters
num
-
Required. A numeric value used to compute the arccosine. It must be between
-1
and1
.
It can be any numeric data type or any non-numeric data type that can be implicitly converted to a numeric data type.
Return Value
The Oracle ACOS()
function returns the arccosine of a given number. It is a value in the range 0 to pi expressed in radians.
If the parameter is of type BINARY_FLOAT
, ACOS()
returns a BINARY_DOUBLE
. Otherwise, ACOS()
returns the same data type as the parameter.
If the parameter is not between -1
and 1
, the ACOS()
function will report an error.
If any parameter is NULL
, ACOS()
will return NULL
.
Oracle ACOS()
Examples
Here are some examples that demonstrate the usage of the Oracle ACOS()
function.
Basic Usage
SELECT
ACOS(0.5)
FROM dual;
Output:
ACOS(0.5)
___________________________________________
1.04719755119659774615421446109316762805
1 and -1
SELECT
ACOS(1),
ACOS(-1)
FROM dual;
Output:
ACOS(1) ACOS(-1)
__________ __________________________________________
0 3.1415926535897932384626433832795028842
Out of Range
If the parameter is not between -1
and 1
, the ACOS()
function will report an error.
SELECT
ACOS(2),
ACOS(-2)
FROM dual;
Output:
SQL Error: ORA-01428: parameter '2' is out of range
01428\. 00000 - "parameter '%s' is out of range"
Non-Numeric Values
If the parameter cannot be converted to a number, ACOS()
will give an error.
SELECT
ACOS('ABC')
FROM dual;
Output:
01722\. 00000 - "invalid number"
*Cause: The specified number was invalid.
*Action: Specify a valid number.
NULL Parameters
If any parameter is NULL
, ACOS()
will return NULL
.
SET NULL 'NULL';
SELECT
ACOS(NULL)
FROM dual;
Output:
ACOS(NULL)
_____________
NULL
In this example, we use the statement SET NULL 'NULL';
to display NULL
values as the string 'NULL'
.
Conclusion
Oracle ACOS()
is a built-in function that returns the arccosine of a given number.