pow()

Returns a base number raised to the power of the specified exponent.

Function properties

ItemDescription
Function typeScalar function
Used inCommands that accept expressions (eval, search, etc.)

Syntax

pow(BASE, EXPONENT)

Parameters

BASE
The base number to exponentiate. Must be a numeric type.
EXPONENT
The exponent. Must be a numeric type.

Description

The pow() function returns BASE raised to the power of EXPONENT as a 64-bit double. Internally uses Math.pow(base, exponent).

Returns null if either BASE or EXPONENT is null or not a numeric type.

Error codes

N/A

Usage examples

To prepare the WEB_APACHE_SAMPLE table used in these examples, refer to Preparing sample data.

  1. Calculate the square of the request size.

    table limit=5 WEB_APACHE_SAMPLE | eval result = pow(bytes, 2)
    | fields bytes, result
    
  2. Calculate the square root using a fractional exponent.

    table limit=5 WEB_APACHE_SAMPLE | eval result = pow(bytes, 0.5)
    | fields bytes, result
    
  3. NULL input

    json "{}" | eval p = pow(null, 2)
    | # p: null
    

Change history

The pow() function is available since before Sonar 4.0.