Skip to content
JervenBolleman edited this page May 31, 2019 · 2 revisions

pow

Signature

 xsd:double  POW ($x as xsd:double?, $y as xsd:numeric)

If $y is an instance of xsd: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.

This function is equivalent to as math:pow.

ASK {FILTER(POW(2, 3) = "8.0e0"^^xsd:double)}
ASK {FILTER(POW(-2, 3) = "-8.0e0"^^xsd:double)}
ASK {FILTER(POW(2, -3) = "0.125e0"^^xsd:double)}
ASK {FILTER(POW(-2, -3) = "-0.125e0"^^xsd:double)}
ASK {FILTER(POW(2, 0) = "1.0e0"^^xsd:double)}
ASK {FILTER(POW(0, 0) = "1.0e0"^^xsd:double)}
ASK {FILTER(POW("INF"^^xsd:double, 0) = "1.0e0"^^xsd:double)}
ASK {FILTER(POW("NaN"^^xsd:double, 0) = "1.0e0"^^xsd:double)}
ASK {FILTER(POW(-math:pi() = 0) = "1.0e0"^^xsd:double)}
ASK {FILTER(POW(0e0, 3) = "0.0e0"^^xsd:double)}
ASK {FILTER(POW(0e0, 4) = "0.0e0"^^xsd:double)}
ASK {FILTER(POW(-0e0, 3) = "-0.0e0"^^xsd:double)}
ASK {FILTER(POW(0, 4) = "0.0e0"^^xsd:double)}
ASK {FILTER(POW(0e0, -3) = "INF"^^xsd:double)}
ASK {FILTER(POW(0e0, -4) = "INF"^^xsd:double)}
ASK {FILTER(POW(-0e0, -3) = "-INF"^^xsd:double)}
ASK {FILTER(POW(0, -4) = "INF"^^xsd:double)}
ASK {FILTER(POW(16, 0.5e0) = "4.0e0"^^xsd:double)}
ASK {FILTER(POW(16, 0.25e0) = "2.0e0"^^xsd:double)}
ASK {FILTER(POW(0e0, -3.0e0) = "INF"^^xsd:double)}
ASK {FILTER(POW(-0e0, -3.0e0) = "-INF"^^xsd:double)}# (Odd-valued whole numbers are treated specially).
ASK {FILTER(POW(0e0, -3.1e0) = "INF"^^xsd:double)}
ASK {FILTER(POW(-0e0, -3.1e0) = "INF"^^xsd:double)}
ASK {FILTER(POW(0e0, 3.0e0) = "0.0e0"^^xsd:double)}
ASK {FILTER(POW(-0e0, 3.0e0) = "-0.0e0"^^xsd:double)} # (Odd-valued whole numbers are treated specially).
ASK {FILTER(POW(0e0, 3.1e0) = "0.0e0"^^xsd:double)}
ASK {FILTER(POW(-0e0, 3.1e0) = "0.0e0"^^xsd:double)}
ASK {FILTER(POW(-1, "INF"^^xsd:double) = "1.0e0"^^xsd:double)}
ASK {FILTER(POW(-1, "-INF"^^xsd:double) = "1.0e0"^^xsd:double)}
ASK {FILTER(POW(1, "INF"^^xsd:double) = "1.0e0"^^xsd:double)}
ASK {FILTER(POW(1, "-INF"^^xsd:double) = "1.0e0"^^xsd:double)}
ASK {FILTER(POW(1, "NaN"^^xsd:double) = "1.0e0"^^xsd:double)}
ASK {FILTER(POW(-2.5e0, 2.0e0) = "6.25e0"^^xsd:double)}
ASK {FILTER(POW(-2.5e0, 2.00000001e0) = "NaN"^^xsd:double)}

Should return true

pow() called without a variable/value should be a parse error. pow() called with 1 variable/value should be a parse error.

pow() called with a numeric as the first ($x parameter) should have that cast to xsd:double.

TODO

Error values