SQLite cos() Function

In SQLite, the cos() function returns the cosine of a value specified in radians.

Syntax

cos(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 cosine.

Return Type

real

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

If x is a string, the cos() function will convert it into a number before calculating the cosine. If the conversion fails, the cos() function returns NULL.

Examples

The following example uses the cos() function to calculate the cosine of zero (0):

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

Output:

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

The following statement uses the cos() function to return the cosine of pi:

SELECT cos(pi()) result;Code language: SQL (Structured Query Language) (sql)

Output:

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