COS | Syntax: | COS(Number) | Return value: | FLOAT | Function type: | Numeric function | |
|
|
The COS() function returns the cosine value of "Number", where "Number" is in radians.
The RADIANS() function can be used to calculate a cosine from an angle value.
The COS() function returns NULL if the value of "Number" is NULL.
|
SQL Examples for the COS function |
|
select radians(45);
select cos(0.7853981633974483);
select cos(radians(45));
select cos(radians(-45));
select round(cos(radians(90)),16);
select cos(radians(180));
select round(cos(radians(270)),16);
select cos(radians(360));
|
|
radians(45) |
double(23) |
0.7853981633974483 |
|
|
cos(0.7853981633974483) |
double(23) |
0.7071067811865476 |
|
|
cos(radians(45)) |
double(23) |
0.7071067811865476 |
|
|
cos(radians(-45)) |
double(23) |
0.7071067811865476 |
|
|
round(cos(radians(90)),16) |
double(33) |
0.0000000000000001 |
|
|
cos(radians(180)) |
double(23) |
-1 |
|
|
round(cos(radians(270)),16) |
double(33) |
-0.0000000000000002 |
|
|
cos(radians(360)) |
double(23) |
1 |
|
|
|
The examples were created with the MyWAY SQL manager: |
How to use the COS() function in MySQL and MariaDB databases |
The COS() function in MySQL and MariaDB returns the cosine value of the angle (in radians) that is the ratio of the length of the adjacent side to the length of the hypotenuse in a right triangle. The function is used in trigonometric calculations and angle applications to calculate angle-related values such as coordinates, distances or projections. |
|
Further MySQL und MariaDB SQL Numeric functions |
|