pow() : Power (Exponentiation)
On this page
Summary
Raise a number to a specified power.
Signature
pow(base, exponent)
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
base |
Number | Yes | The base value |
exponent |
Number | Yes | The power to raise to |
Returns
Type: Double
The base raised to the power of the exponent.
Examples
Square
Data:
doc.Params["model"] = new {
value = 5
};
Output:
<p>5 squared = 25</p>
Cube
Data:
doc.Params["model"] = new {
side = 3
};
Output:
<p>Volume: 27 cubic units</p>
Compound Interest
Data:
doc.Params["model"] = new {
principal = 1000,
rate = 0.05,
years = 10
};
Output:
<p>Future Value: $1628.89</p>
Nth Root
Output:
<p>Cube root of 27: 3.0</p>
Notes
- Alternative to
^operator - Returns double-precision floating-point
- Supports fractional exponents (for roots)
- Supports negative exponents (for reciprocals)
pow(x, 0.5)is same assqrt(x)pow(x, -1)calculates 1/x