Converts $string-var (a string) to a double precision (64 bit) floating point value.
The data type double corresponds to IEEE double-precision 64-bit floating point type (IEEE 754-1985).
If the value of $string-var is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items (), which is similar to null in SQL.
xs:double(xs:string $string-var) —> xs:double
Represents the string to convert to a double. |
Returns the double precision floating point value of $string-var.
Invoking double("1.1")returns the double precision floating point value of 1.1 as shown in the following example query:
<double>{xs:double("1.1")}</double>
The preceding query generates the following result:
<double>1.1</double>
Invoking double("-104.345e2")returns the double floating point value of -10434.5 as shown in the following example query:
<double>{xs:double("-104.345e2")}</double>
The preceding query generates the following result:
<double>-10434.5</double>
The string: NaN (Not a Number) is a legal argument, as shown in the following example query:
<double>{xs:double("NaN")}</double>
The preceding query generates the following result:
<double>NaN</double>
The strings: INF (positive infinity) and -INF (negative infinity) are legal arguments as shown in the following example query:
<infinity> <positive>{xs:double("INF")}</positive> <negative>{xs:double("-INF")}</negative> </infinity>
The preceding query generates the following result:
<infinity> <positive>Infinity</positive> <negative>-Infinity</negative> </infinity>
Invoking double("10.1e2.1") outputs an error because 2.1 is not an integer. For example, the following example query:
<double>{xs:double("10.1e2.1")}</double>
Error occurred while executing XQuery: Could not cast "10.1e2.1" to type [double@http://www.w3.org/2001/XMLSchema]
Invoking double(()) returns the empty sequence. The empty sequence is a sequence containing zero items (), which is similar to null in SQL
For example, the following example query:
<double>{xs:double(())}</double>
The preceding query generates the following result:
<double/>
W3C double data type description