cos()
The cos() function returns the cosine of an angle given in radians.
Syntax
cos(NUM_EXPR)
Parameters
NUM_EXPR- An angle expression in radians whose cosine is to be computed.
Description
The cos() function applies Math.cos() to the input and returns the result as a 64-bit double. If the input is a Number type, it is internally converted using doubleValue() before processing.
Returns null if the input is null or not a number.
Error codes
N/A
Usage examples
-
Calculate the cosine of 0 degrees.
json "{'val': 0}" | eval result = cos(val) | # result: 1.0 -
Calculate the cosine of 60 degrees.
json "{'val': 1.0471975511965976}" | eval result = cos(val) | # result: 0.5000000000000001 -
NULL input
json "{'val': null}" | eval result = cos(val) | # result: null
Compatibility
The cos() function is available since before Sonar 4.0.