Power

Arithmetic Pure Generic
Power
Base 2
Result
Exponent 2

Description

Pure function returning base raised to the exponent. Generic on both operands, resolving to INTEGER or DECIMAL at design-time. Integer powers require a non-negative exponent; decimal powers allow negative and fractional exponents (e.g. roots).

When to use

Use Power when you need to raise a number to a known exponent, such as computing byte boundaries (2^10 = 1024) or exponential backoff intervals. Both operands are generic and resolve together to integer or decimal when the first connection is made. With integers the exponent must be non-negative — guard against negative values through Greater than or equal? if the exponent comes from external input. With decimals you can use negative exponents (2^-1 = 0.5) and fractional exponents to take roots (9^0.5 = 3). For simple doubling or squaring, Multiply with the same value on both pins is equivalent but Power is more readable.

Pins

Input pins

Pin Type Default Notes
Base generic(integer, decimal) 2 The base value. Its type is resolved to integer or decimal when the first connection is made.
Exponent generic(integer, decimal) 2 The exponent. For integers it must be non-negative; for decimals negative and fractional exponents are allowed.

Output pins

Pin Type Notes
Result generic(integer, decimal) base raised to the power of exponent.

Example

Compute an exponential backoff delay for a retry attempt number. Wire the attempt number into the Exponent input of Power with Base set to 2. Feed the Result output into the A input of Multiply with B set to 1000 to convert to milliseconds, then wire the Result output into the Duration (ms) input of Sleep to pause before retrying.

See also