double()
Converts a value to a 64-bit double-precision floating-point number.
Syntax
Parameters
EXPR- The value or expression to convert to a floating-point number.
Description
The double() function converts the argument to a 64-bit double-precision floating-point number (double) and returns it. If the argument is null, returns null. If conversion fails, also returns null.
Numeric types (integer, long, etc.) are converted directly to double. For strings, Double.parseDouble() is used for parsing. An empty string returns null. If an array or list is passed, the conversion is applied recursively to each element.
Error codes
N/A
Usage examples
To prepare the WEB_APACHE_SAMPLE table used in these examples, refer to Preparing sample data.
-
Converting the
bytesinteger field to a floating-point numbertable limit=5 WEB_APACHE_SAMPLE | eval result = double(bytes) | fields bytes, result | # result: 2780.0, 162.0, etc. -
Converting a string to a floating-point number
json "{'val': '3.14'}" | eval result = double(val) | # result: 3.14 -
Non-convertible string
json "{'val': 'abc'}" | eval result = double(val) | # result: null -
NULL input
json "{'val': null}" | eval result = double(val) | # result: null
Compatibility
The double() function has been available since before Sonar 4.0.