<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/fn.number.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>fn.number</api:function-name><api:suggest>fn.number</api:suggest><api:suggest>fn</api:suggest><api:suggest>number</api:suggest><api:function-link mode="xquery" fullname="fn:number">/apidoc/8.0/fn:number.xml</api:function-link><api:function mode="javascript" name="number" type="builtin" lib="fn" category="NodeBuiltins" bucket="W3C-Standard Functions" hidden="false" prefix="fn" namespace="http://www.w3.org/2005/xpath-functions" fullname="fn.number"><api:summary>
<p xmlns="http://www.w3.org/1999/xhtml">
Returns the value indicated by $arg or, if $arg is not specified, the context
item after atomization, converted to an xs:double. If $arg is the empty
sequence or if $arg or the context item cannot be converted to an xs:double,
the xs:double value NaN is returned. If the context item is undefined an
error is raised: [err:XPDY0002].
</p><p xmlns="http://www.w3.org/1999/xhtml">
Calling the zero-argument version of the function is defined to give the same
result as calling the single-argument version with an argument of ".". That
is, fn:number() is equivalent to fn:number(.).
</p><p xmlns="http://www.w3.org/1999/xhtml">
If $arg is the empty sequence, NaN is returned. Otherwise, $arg, or the context
item after atomization, is converted to an xs:double following the rules of
17.1.3.2 Casting to xs:double. If the conversion to xs:double fails, the
xs:double value NaN is returned.
</p>
</api:summary><api:params><api:param name="arg" type="xs:anyAtomicType?" optional="true"><api:param-description>
The value to be returned as an xs:double value.
  </api:param-description><api:param-name>arg</api:param-name><api:param-type>xs.anyAtomicType?</api:param-type></api:param></api:params><api:return>Number</api:return><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
var item1 = xdmp.unquote('&lt;a&gt;&lt;quantity&gt;5.0&lt;/quantity&gt;&lt;/a&gt;').toArray()[0].root
fn.number(item1.xpath("/a/quantity"));
=&gt; 5

var item1 = xdmp.unquote('&lt;a&gt;&lt;quantity&gt;5.0&lt;/quantity&gt;&lt;/a&gt;').toArray()[0].root
fn.number(item1.xpath("/quantity"));
=&gt; NaN 
</pre></api:example></api:function></api:function-page>