fn:abs
Returns the absolute value of $arg.
Signature
fn:abs($arg as xs:numeric?) as xs:numeric?Properties
This function is deterministic, context-independent, and focus-independent.
Rules
General rules: see Functions on numeric values.
If $arg is negative the function returns -$arg, otherwise it
returns $arg.
For the four types xs:float,
xs:double, xs:decimal and xs:integer, it is
guaranteed that if the type of $arg is an instance of type T then
the result will also be an instance of T. The result may
also be an instance of a type derived from one of these four by restriction. For example,
if
$arg is an instance of xs:positiveInteger then the value of
$arg may be returned unchanged.
For xs:float and xs:double arguments, if the argument is
positive zero or negative zero, then positive zero is returned. If the argument is
positive or negative infinity, positive infinity is returned.
Examples
The expression fn:abs(10.5) returns 10.5.
The expression fn:abs(-10.5) returns 10.5.