COS
Returns the cosine of an angle given in radians.
MySQL 8.1
COS(angle)Parameters
- angleDOUBLE
- Angle in radians
Return value
A floating-point number from -1 to 1
Examples
Cosine of a straight angle
MySQL 8.1
SELECT COS(PI());Cosine of 60° rounded
MySQL 8.1
SELECT COS(RADIANS(60)) AS raw,
ROUND(COS(RADIANS(60)), 2) AS rounded;Details
To convert degrees to radians, use the RADIANS function: COS(RADIANS(60)).
COS(PI() / 2) gives about 6e-17, not exactly 0.