Calculates the rounded positive square root of a double field.
Note
Math functions on ARM architecture may return different results in very high-precision calculationsc compared to Intel/AMD architectures.
Hide omitted argument names for this function
Omitted Argument NamesThe argument name for
field
can be omitted; the following forms of this function are equivalent:logscale Syntaxmath:sqrt("value")
and:
logscale Syntaxmath:sqrt(field="value")
These examples show basic structure only.
math:sqrt()
Examples
Click
next to an example below to get the full details.Calculate Rounded Square Root Values
Find and round square roots using the
math:sqrt()
function
Query
myvalue := 100
| math:sqrt(myvalue, as=square_root)
Introduction
In this example, the math:sqrt()
function is used
to calculate the square root of an assigned value. The input must be a
numeric field that can contain decimal values (floating-point numbers).
Step-by-Step
Starting with the source repository events.
- logscale
myvalue := 100
Assigns the value
100
to a field named myvalue. This creates a new field with a constant value that will be used for the square root calculation. - logscale
| math:sqrt(myvalue, as=square_root)
Takes the square root of the value in the myvalue field and returns the result in a new field named square_root. The function automatically rounds the result to the nearest integer. In this case, it calculates the square root of
100
, which is10
.Note that - if not returning an exact integer, the function rounds the result to the nearest integer in case of non-perfect squares. For example:
Square root of
90 = 9.487
rounds to9
.Square root of
91 = 9.539
rounds to10
. Event Result set.
Summary and Results
The query is used to calculate the square root of an assigned constant value, demonstrating how to combine value assignment with mathematical functions.
This query is useful, for example, to perform calculations on fixed values or to add reference calculations to existing event data.
Sample output from the incoming example data:
square_root |
---|
10 |