SQLite Tutorial SQLite Advanced SQLite Database SQLite References

SQLite ACOS() Function



The SQLite 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 NULL 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.

SELECT ACOS(0.2);
Result: 1.36943840600457

SELECT ACOS(0.8);
Result: 0.643501108793284

SELECT ACOS(1);
Result: 0.0

SELECT ACOS(-1);
Result: 3.14159265358979

SELECT ACOS(0);
Result: 1.5707963267949

SELECT ACOS(-0.2);
Result: 1.77215424758523

SELECT ACOS(-2);
Result: NULL

Example 2:

Consider a database table called Sample with the following records:

Datax
Data 1-1
Data 2-0.5
Data 30
Data 40.5
Data 51

The statement given below can be used to calculate the arc cosine of records of column x.

SELECT *, ACOS(x) AS ACOS_Value FROM Sample;

This will produce the result as shown below:

DataxACOS_Value
Data 1-13.14159265358979
Data 2-0.52.0943951023932
Data 301.5707963267949
Data 40.51.0471975511966
Data 510.0

❮ SQLite Functions