SQLite tan() Function

In SQLite, the tan() function calculates the tangent of a value in radians.

Syntax

tan(x)Code language: SQL (Structured Query Language) (sql)

Arguments

x

x is a number, an expression, or a table column that you want to calculate the tangent. x is in radians.

Return Type

real

The function returns the tangent of x in radians. If x is NULL, the function returns NULL.

If x is a string, the tan() function will convert the value into a number before calculating the tangent. If the conversion fails, the tan() function returns NULL.

Examples

The following example uses the tan() function to calculate the tangent of zero (0):

SELECT tan(0) result;Code language: SQL (Structured Query Language) (sql)

Output:

result
------
0.0Code language: SQL (Structured Query Language) (sql)

The following statement uses the tan() function to return the tangent of pi/4:

SELECT round(tan(pi()/4)) result;Code language: SQL (Structured Query Language) (sql)

Output:

result
------
1.0Code language: SQL (Structured Query Language) (sql)
Was this tutorial helpful ?