xs:double

The primitive type xs:double is patterned after an IEEE double-precision 64-bit floating-point number. The lexical representation is a mantissa (a decimal number) followed, optionally, by the letter E (in upper or lowercase), followed by an integer exponent. For example, 3E2 represents 3 × 102, or 300. In addition, there are three special values: INF, (infinity), -INF (negative infinity), and NaN (not a number).

Table B-8 lists some values of the xs:double type.

Table B-8. Values of the xs:double type

Values

Explanation

Valid

 
−5E12
 
44.56E5
 
+23.2e−2
 
12
 
+3.5

Any value valid for xs:decimal is also valid for xs:float and xs:double

−0

Negative zero

INF

Positive infinity

NaN

Not a number

Invalid

 
−5E3.5

The exponent must be an integer

 37E

An exponent must be specified if E is present

 

An empty value or zero-length string is not permitted

XQuery makes a distinction between positive and negative zero values for the xs:double type. 0 and −0 are considered to be equal but separate values.

The implementation has some flexibility regarding how to handle overflow or underflow during arithmetic operations on xs:double values. The processor may raise an error. Alternatively, in an overflow situation, it may return INF, -INF, or the largest or smallest possible value. For underflow, it may return the closest possible value to zero.

Casting xs:double Values

Values of type xs:double can be cast to and from any of the other numeric types. Casting among numeric types is straightforward if the value is in the value space of both types. For example, casting an xs:double value 12.5E0 to xs:float results in a value 12.5E0 whose type is xs:float.

However, some xs:double values are either too large or are otherwise not represented in the value spaces of xs:float, xs:decimal, or xs:integer. See the descriptions of these types for more information.

Values of type xs:double can also be cast to and from xs:string, xs:untypedAtomic, and xs:boolean. When cast to xs:string, if the value is between 0.000001 (inclusive) and 1,000,000 (exclusive), the value is represented as a decimal. It will have no exponent, no positive sign, and no leading or trailing zeros, except that there will always be at least one digit before the decimal point. If there is no fractional part, the decimal point is omitted. If the value is outside that range, it is represented using an exponent as shown in the first three examples in Table B-8.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.12.123.189