math:pow
Returns the result of raising the first argument to the power of the second.
Signature
math:pow(
$x as xs:double?,
$y as xs:numeric
) as xs:double?
Properties
This function is deterministic, context-independent, and focus-independent.
Rules
If $x
is the empty sequence, the function returns the empty sequence.
If $y
is an instance of xs:integer
, the result is
$x
raised to the power of $y
as defined in the [IEEE 754-2008] specification of the pown
function applied to a
64-bit binary floating point value and an integer.
Otherwise $y
is converted to an xs:double
by numeric
promotion, and the result is the value of $x
raised to the power of
$y
as defined in the [IEEE 754-2008] specification of the
pow
function applied to two 64-bit binary floating point values.
Notes
The treatment of the divideByZero
and invalidOperation
exceptions is defined in Arithmetic operators on numeric values. Some of the consequences are
illustrated in the examples below.
Examples
The expression math:pow((), 93.7)
returns ()
.
The expression math:pow(2, 3)
returns 8.0e0
.
The expression math:pow(-2, 3)
returns -8.0e0
.
The expression math:pow(2, -3)
returns 0.125e0
.
The expression math:pow(-2, -3)
returns -0.125e0
.
The expression math:pow(2, 0)
returns 1.0e0
.
The expression math:pow(0, 0)
returns 1.0e0
.
The expression math:pow(xs:double('INF'), 0)
returns 1.0e0
.
The expression math:pow(xs:double('NaN'), 0)
returns 1.0e0
.
The expression math:pow(-math:pi(), 0)
returns 1.0e0
.
The expression math:pow(0e0, 3)
returns 0.0e0
.
The expression math:pow(0e0, 4)
returns 0.0e0
.
The expression math:pow(-0e0, 3)
returns -0.0e0
.
The expression math:pow(0, 4)
returns 0.0e0
.
The expression math:pow(0e0, -3)
returns xs:double('INF')
.
The expression math:pow(0e0, -4)
returns xs:double('INF')
.
The expression math:pow(-0e0, -3)
returns xs:double('-INF')
.
The expression math:pow(0, -4)
returns xs:double('INF')
.
The expression math:pow(16, 0.5e0)
returns 4.0e0
.
The expression math:pow(16, 0.25e0)
returns 2.0e0
.
The expression math:pow(0e0, -3.0e0)
returns xs:double('INF')
.
The expression math:pow(-0e0, -3.0e0)
returns xs:double('-INF')
. (Odd-valued whole numbers are treated specially).
The expression math:pow(0e0, -3.1e0)
returns xs:double('INF')
.
The expression math:pow(-0e0, -3.1e0)
returns xs:double('INF')
.
The expression math:pow(0e0, 3.0e0)
returns 0.0e0
.
The expression math:pow(-0e0, 3.0e0)
returns -0.0e0
. (Odd-valued whole numbers are treated specially).
The expression math:pow(0e0, 3.1e0)
returns 0.0e0
.
The expression math:pow(-0e0, 3.1e0)
returns 0.0e0
.
The expression math:pow(-1, xs:double('INF'))
returns 1.0e0
.
The expression math:pow(-1, xs:double('-INF'))
returns 1.0e0
.
The expression math:pow(1, xs:double('INF'))
returns 1.0e0
.
The expression math:pow(1, xs:double('-INF'))
returns 1.0e0
.
The expression math:pow(1, xs:double('NaN'))
returns 1.0e0
.
The expression math:pow(-2.5e0, 2.0e0)
returns 6.25e0
.
The expression math:pow(-2.5e0, 2.00000001e0)
returns xs:double('NaN')
.