XPath/XQuery sqrt function


Returns the non-negative square root of the argument.


$arg as xs:double?
) as xs:double?


This function is deterministic, context-independent, and focus-independent.


If $arg is the empty sequence, the function returns the empty sequence.

Otherwise the result is the mathematical non-negative square root of $arg as defined in the specification of the squareRoot function applied to 64-bit binary floating point values.


The expression math:sqrt(()) returns ().

The expression math:sqrt(0.0e0) returns 0.0e0.

The expression math:sqrt(-0.0e0) returns -0.0e0.

The expression math:sqrt(1.0e6) returns 1.0e3.

The expression math:sqrt(2.0e0) returns 1.4142135623730951e0.

The expression math:sqrt(-2.0e0) returns xs:double('NaN').

The expression math:sqrt(xs:double('NaN')) returns xs:double('NaN').

The expression math:sqrt(xs:double('INF')) returns xs:double('INF').

The expression math:sqrt(xs:double('-INF')) returns xs:double('NaN').


The treatment of the invalidOperation exception is defined in . The effect is that if the argument is less than zero, the result is NaN.

If $arg is positive or negative zero, positive infinity, or NaN, then the result is $arg. (Negative zero is the only case where the result can have negative sign)