Power
Synopsis
Raises a numeric value to a specified power and returns the result.
Schema
- power:
field: <ident>
left_operand: <string>
right_operand: <string>
description: <text>
if: <script>
ignore_failure: <boolean>
ignore_missing: <boolean>
on_failure: <processor[]>
on_success: <processor[]>
tag: <string>
Configuration
The following fields are used to define the processor:
Field | Required | Default | Description |
---|---|---|---|
field | Y | - | Target field to store the power operation result |
left_operand | Y | - | Base value to be raised to a power - can be a literal value or field reference |
right_operand | Y | - | Exponent value - can be a literal value or field reference |
description | N | - | Explanatory note |
if | N | - | Condition to run |
ignore_failure | N | false | Continue processing if power operation fails |
ignore_missing | N | false | Skip if referenced fields don't exist |
on_failure | N | - | Error handling processors |
on_success | N | - | Success handling processors |
tag | N | - | Identifier |
Details
Raises a numeric value (the base) to a specified power (the exponent) and stores the result in the target field. The processor handles various special cases and mathematical constraints associated with exponentiation.
The processor uses the math.Pow
function from Go's standard library to perform the calculation, which provides accurate results for a wide range of inputs.
The processor is useful for exponential calculations, scaling operations, scientific computations, and implementing mathematical formulas that involve powers.
The processor handles several special mathematical cases:
- 0^0 is considered indeterminate and will cause an error
- Negative numbers raised to non-integer powers will result in complex numbers and cause an error
- Very large results might overflow and cause an error
- Results that are not finite numbers (NaN or Infinity) will cause an error
Always provide appropriate error handling for operations that might encounter these edge cases.
Examples
Basic
Raising a number to a power... |
|
calculates the result: |
|
Square and Cube
Calculating square and cube of a value... |
|
computes common powers: |
|
Scientific
Implementing scientific notation... |
|
calculates 2.5 × 10^4: |
|
Area and Volume
Calculating area and volume from side length... |
|
computes geometric properties: |
|
Compound Interest
Calculating compound interest... |
|
implements compound interest formula: |
|