log()
The log() function returns the natural logarithm (base e) of the input value.
Syntax
log(NUM_EXPR)
Parameters
NUM_EXPR- A numeric expression whose natural logarithm is to be computed.
Description
The log() function applies Math.log() 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. Returns negative infinity (-Infinity) if the input is 0. Returns NaN if the input is negative.
Error codes
N/A
Usage examples
-
Calculate the natural logarithm.
json "{'val': 10}" | eval result = log(val) | # result: 2.302585092994046 -
Calculate the natural logarithm of e.
json "{'val': 2.718281828459045}" | eval result = log(val) | # result: 1.0 -
NULL input
json "{'val': null}" | eval result = log(val) | # result: null
Compatibility
The log() function is available since before Sonar 4.0.