COS (SQL)
A scalar numeric function that returns the cosine, in radians, of an angle.
Synopsis
{fn COS(numeric-expression)}
Arguments
Argument | Description |
---|---|
numeric-expression | A numeric expression. This is an angle expressed in radians. |
COS returns either the NUMERIC or DOUBLE data type. If numeric-expression is data type DOUBLE, COS returns DOUBLE; otherwise, it returns NUMERIC.
Description
COS takes any numeric value and returns the cosine as a floating point number. The returned value is within the range -1 to 1, inclusive. COS returns NULL if passed a NULL value. COS treats nonnumeric strings as the numeric value 0.
COS returns a value with a precision of 19 and a scale of 18.
COS can only be used as an ODBC scalar function (with the curly brace syntax).
You can use the DEGREES function to convert radians to degrees. You can use the RADIANS function to convert degrees to radians.
Examples
These examples show the effect of COS on two sines.
SELECT {fn COS(0.52)} AS Cosine
returns 0.86781.
SELECT {fn COS(-.31)} AS Cosine
returns 0.95233.