Skip to content

power

Description

Returns the result of raising a number to the power of an exponent.

Syntax

Like many functions in DataPrime, power supports two notations, function and method notation. These interchangeable forms allow flexibility in how you structure expressions.

power(number: number, exponent: number): number
(number: number).power(exponent: number): number

Arguments

NameTypeRequiredDescription
numbernumbertrueThe base value to raise
exponentnumbertrueThe exponent to raise the base to (e.g. 2 squares the base)

Example

Use case: Square a number

Raise a numeric field to the power of 2 to calculate its square.

{
    "num": 7
}
create num_squared from power(num, 2)
create num_squared from num.power(2)

Output

  {
      "num": 7,
      "num_squared": 49
  }