Skip to main content Link Search Menu Expand Document (external link)

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

<p> squared = </p>

Data:

doc.Params["model"] = new {
    value = 5
};

Output:

<p>5 squared = 25</p>

Cube

<p>Volume:  cubic units</p>

Data:

doc.Params["model"] = new {
    side = 3
};

Output:

<p>Volume: 27 cubic units</p>

Compound Interest

<p>Future Value: $</p>

Data:

doc.Params["model"] = new {
    principal = 1000,
    rate = 0.05,
    years = 10
};

Output:

<p>Future Value: $1628.89</p>

Nth Root

<!-- Cube root using pow(value, 1/3) -->
<p>Cube root of 27: </p>

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 as sqrt(x)
  • pow(x, -1) calculates 1/x

See Also