In SQLite, the atan()
function calculates the arctangent of a number and returns the result in radians.
Syntax
atan(x)
Code language: SQL (Structured Query Language) (sql)
Arguments
x
x is the number that you want to calculate the arc tangent. x can be a literal number, an expression, or a table column.
Return Type
float
The atan()
function returns the arc tangent of x in radians. It returns NULL
if x is NULL
.
If x is a string, the atan()
function will convert it to a number before calculation. If the conversation fails, the atan()
function returns NULL
.
Examples
The following example uses the atan()
function to return the arc tan of zero:
SELECT atan(0) result;
Code language: SQL (Structured Query Language) (sql)
Output:
result
------
0.0
Code language: SQL (Structured Query Language) (sql)
The following example uses the atan()
function to calculate the arc tangent of one:
SELECT atan(1) result;
Code language: SQL (Structured Query Language) (sql)
Output:
result
------------------
0.7853981633974483
Code language: SQL (Structured Query Language) (sql)
The result is in radians. If you want the result in degrees, you can use the degrees()
function to convert it:
SELECT degrees(atan(1)) result;
Code language: SQL (Structured Query Language) (sql)
Output:
result
------
45.0
Code language: SQL (Structured Query Language) (sql)
It returns 45 degrees.