<apidoc:module name="NumericBuiltins" category="NumericBuiltins" lib="fn" xmlns:apidoc="http://marklogic.com/xdmp/apidoc"><apidoc:summary access="public" category="NumericBuiltins" bucket="W3C-Standard Functions">
The numeric built-in functions are XQuery functions defined to operate on 
numeric values. They are defined in
<a href="http://www.w3.org/TR/xpath-functions/" xmlns="http://www.w3.org/1999/xhtml">XQuery 1.0 
and XPath 2.0 Functions and Operators</a>. 
</apidoc:summary><apidoc:function name="abs" type="builtin" lib="fn" category="NumericBuiltins" bucket="W3C-Standard Functions" hidden="false">
    <apidoc:summary>
<p xmlns="http://www.w3.org/1999/xhtml">
Returns the absolute value of $arg. If $arg is negative returns -$arg 
otherwise returns $arg. If type of $arg is one of the four numeric types
xs:float, xs:double, xs:decimal or xs:integer the type of the result is
the same as the type of $arg. If the type of $arg is a type derived from
one of the numeric types, the result is an instance of the base numeric 
type.  
</p><p xmlns="http://www.w3.org/1999/xhtml">
For xs:float and xs:double arguments, if the argument is positive zero (+0) 
or negative zero (-0), then positive zero (+0) is returned. If the argument
is positive or negative infinity, positive infinity is returned.
</p><p xmlns="http://www.w3.org/1999/xhtml">
For detailed type semantics, see Section 7.2.1 The fn:abs, fn:ceiling, 
fn:floor, fn:round, and fn:round-half-to-even functions of [XQuery 1.0 and
XPath 2.0 Formal Semantics].
</p>
</apidoc:summary>
    <apidoc:params>
      <apidoc:param name="arg" type="numeric?" optional="false">
A numeric value.
  </apidoc:param>
    </apidoc:params>
    <apidoc:return>numeric?</apidoc:return>
    <apidoc:example><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
fn:abs(10.5) returns 10.5.<br/>
fn:abs(-10.5) returns 10.5.
</pre></apidoc:example>
  </apidoc:function><apidoc:function name="ceiling" type="builtin" lib="fn" category="NumericBuiltins" bucket="W3C-Standard Functions" hidden="false">
    <apidoc:summary>
<p xmlns="http://www.w3.org/1999/xhtml">
Returns the smallest (closest to negative infinity) number with no fractional
part that is not less than the value of $arg. If type of $arg is one of the
four numeric types xs:float, xs:double, xs:decimal or xs:integer the type of
the result is the same as the type of $arg. If the type of $arg is a type
derived from one of the numeric types, the result is an instance of the base
numeric type. 
</p><p xmlns="http://www.w3.org/1999/xhtml">
For xs:float and xs:double arguments, if the argument is positive zero, then
positive zero is returned. If the argument is negative zero, then negative zero
is returned. If the argument is less than zero and greater than -1, negative
zero is returned. 
</p><p xmlns="http://www.w3.org/1999/xhtml">
For detailed type semantics, see Section 7.2.3 The fn:abs, fn:ceiling, 
fn:floor, fn:round, and fn:round-half-to-even functions[FS].
</p>
</apidoc:summary>
    <apidoc:params>
      <apidoc:param name="arg" type="numeric?" optional="false">
A numeric value.
  </apidoc:param>
    </apidoc:params>
    <apidoc:return>numeric?</apidoc:return>
    <apidoc:example><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
fn:ceiling(10.5) returns 11.
fn:ceiling(-10.5) returns -10.
</pre></apidoc:example>
  </apidoc:function><apidoc:function name="floor" type="builtin" lib="fn" category="NumericBuiltins" bucket="W3C-Standard Functions" hidden="false">
    <apidoc:summary>
<p xmlns="http://www.w3.org/1999/xhtml">
Returns the largest (closest to positive infinity) number with no fractional
part that is not greater than the value of $arg. If type of $arg is one of the
four numeric types xs:float, xs:double, xs:decimal or xs:integer the type of
the result is the same as the type of $arg. If the type of $arg is a type
derived from one of the numeric types, the result is an instance of the base
numeric type.
</p><p xmlns="http://www.w3.org/1999/xhtml">
For float and double arguments, if the argument is positive zero, then positive
zero is returned. If the argument is negative zero, then negative zero is
returned.
</p><p xmlns="http://www.w3.org/1999/xhtml">
For detailed type semantics, see Section 7.2.3 The fn:abs, fn:ceiling,
fn:floor, fn:round, and fn:round-half-to-even functions[FS].
</p>
</apidoc:summary>
    <apidoc:params>
      <apidoc:param name="arg" type="numeric?" optional="false">
A numeric value.
  </apidoc:param>
    </apidoc:params>
    <apidoc:return>numeric?</apidoc:return>
    <apidoc:example><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
fn:floor(10.5) returns 10.<br/>
fn:floor(-10.5) returns -11.
</pre></apidoc:example>
  </apidoc:function><apidoc:function name="round" type="builtin" lib="fn" category="NumericBuiltins" bucket="W3C-Standard Functions" hidden="false">
    <apidoc:summary>
<p xmlns="http://www.w3.org/1999/xhtml">
Returns the number with no fractional part that is closest to the argument. If
there are two such numbers, then the one that is closest to positive infinity
is returned. If type of $arg is one of the four numeric types xs:float,
xs:double, xs:decimal or xs:integer the type of the result is the same as the
type of $arg. If the type of $arg is a type derived from one of the numeric
types, the result is an instance of the base numeric type.
</p><p xmlns="http://www.w3.org/1999/xhtml">
For xs:float and xs:double arguments, if the argument is positive infinity,
then positive infinity is returned. If the argument is negative infinity, then
negative infinity is returned. If the argument is positive zero, then positive
zero is returned. If the argument is negative zero, then negative zero is
returned. If the argument is less than zero, but greater than or equal to -0.5,
then negative zero is returned. In the cases where positive zero or negative
zero is returned, negative zero or positive zero may be returned as [XML Schema
Part 2: Datatypes Second Edition] does not distinguish between the values
positive zero and negative zero. 
</p><p xmlns="http://www.w3.org/1999/xhtml">
For the last two cases, note that the result is not the same as fn:floor(x+0.5).
</p><p xmlns="http://www.w3.org/1999/xhtml">
For detailed type semantics, see Section 7.2.3 The fn:abs, fn:ceiling, fn:floor,
fn:round, and fn:round-half-to-even functions[FS].
</p>
</apidoc:summary>
    <apidoc:params>
      <apidoc:param name="arg" type="numeric?" optional="false">
A numeric value to round.
  </apidoc:param>
    </apidoc:params>
    <apidoc:return>numeric?</apidoc:return>
    <apidoc:example><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
fn:round(2.5) returns 3.<br/>
fn:round(2.4999) returns 2.<br/>
fn:round(-2.5) returns -2 (not the possible alternative, -3).
</pre></apidoc:example>
  </apidoc:function><apidoc:function name="round-half-to-even" type="builtin" lib="fn" category="NumericBuiltins" bucket="W3C-Standard Functions" hidden="false">
    <apidoc:summary>
<p xmlns="http://www.w3.org/1999/xhtml">
The value returned is the nearest (that is, numerically closest) numeric to
$arg that is a multiple of ten to the power of minus $precision. If two such
values are equally near (e.g. if the fractional part in $arg is exactly
.500...), returns the one whose least significant digit is even. If type of
$arg is one of the four numeric types xs:float, xs:double, xs:decimal or
xs:integer the type of the result is the same as the type of $arg. If the type
of $arg is a type derived from one of the numeric types, the result is an
instance of the base numeric type. 
</p><p xmlns="http://www.w3.org/1999/xhtml">
If no precision is specified, the result produces is the same as with
$precision=0. 
</p><p xmlns="http://www.w3.org/1999/xhtml">
For arguments of type xs:float and xs:double, if the argument is positive zero,
then positive zero is returned. If the argument is negative zero, then negative
zero is returned. If the argument is less than zero, but greater than or equal
o -0.5, then negative zero is returned. 
</p><p xmlns="http://www.w3.org/1999/xhtml">
If $arg is of type xs:float or xs:double, rounding occurs on the value of the
mantissa computed with exponent = 0. 
</p><p xmlns="http://www.w3.org/1999/xhtml">
For detailed type semantics, see Section 7.2.3 The fn:abs, fn:ceiling,
fn:floor, fn:round, and fn:round-half-to-even functions[FS].
</p>
</apidoc:summary>
    <apidoc:params>
      <apidoc:param name="arg" type="numeric?" optional="false">
A numeric value to round.
  </apidoc:param>
      <apidoc:param name="precision" type="xs:integer" optional="true">
The precision to which to round the value.
  </apidoc:param>
    </apidoc:params>
    <apidoc:return>numeric?</apidoc:return>
    <apidoc:example><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
fn:round-half-to-even(0.5) returns 0.<br/>
fn:round-half-to-even(1.5) returns 2.<br/>
fn:round-half-to-even(2.5) returns 2.<br/>
fn:round-half-to-even(3.567812E+3, 2) returns 3567.81E0.<br/>
fn:round-half-to-even(4.7564E-3, 2) returns 0.0E0.<br/>
fn:round-half-to-even(35612.25, -2) returns 35600.<br/>
</pre></apidoc:example>
  </apidoc:function></apidoc:module>