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. These interchangeable forms allow flexibility in how you structure expressions.
- Function notation
- Method notation
power(number: number, exponent: number): number
(number: number).power(exponent: number): number
Arguments
| Name | Type | Required | Description |
|---|---|---|---|
number | number | true | The base value to raise |
exponent | number | true | The 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.
Example data
{
"num": 7
}
Example query
- Function notation
- Method notation
create num_squared from power(num, 2)
create num_squared from num.power(2)
Example output
{
"num": 7,
"num_squared": 49
}