<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/math.trunc.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>math.trunc</api:function-name><api:suggest>math.trunc</api:suggest><api:suggest>math</api:suggest><api:suggest>trunc</api:suggest><api:function-link mode="xquery" fullname="math:trunc">/apidoc/8.0/math:trunc.xml</api:function-link><api:function mode="javascript" name="trunc" type="builtin" lib="math" category="MathBuiltins" hidden="false" bucket="MarkLogic Built-In Functions" prefix="math" namespace="http://marklogic.com/xdmp/math" fullname="math.trunc"><api:summary>
<p xmlns="http://www.w3.org/1999/xhtml">
Returns the number truncated to a certain number of decimal places.
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. 
</p>
</api:summary><api:params><api:param name="arg" type="numeric?"><api:param-description>
A numeric value to truncate.
  </api:param-description><api:param-name>arg</api:param-name><api:param-type>numeric?</api:param-type></api:param><api:param name="n" type="xs:integer" optional="true"><api:param-description>
The numbers of decimal places to truncate to. The default is 0. Negative values
cause that many digits to the left of the decimal point to be truncated.
  </api:param-description><api:param-name>n</api:param-name><api:param-type>Number</api:param-type></api:param></api:params><api:return>numeric?</api:return><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
math.trunc(125.815)	returns 125
math.trunc(125.815, 0)	returns 125
math.trunc(125.815, 1)	returns 125.8
math.trunc(125.815, 2)	returns 125.81
math.trunc(125.815, 3)	returns 125.815
math.trunc(-125.815, 2)	returns -125.81
math.trunc(125.815, -1)	returns 120
math.trunc(125.815, -2)	returns 100
math.trunc(125.815, -3)	returns 0
</pre></api:example></api:function></api:function-page>