Loading TOC...


   [$arg as xs:anyAtomicType?]
) as xs:double


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].

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(.).

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 Casting to xs:double. If the conversion to xs:double fails, the xs:double value NaN is returned.

arg The value to be returned as an xs:double value.


=> 5.0

=> NaN

Assume that the context item is the xs:string "15".
fn:number() returns 1.5E1.

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.