The primitive type xs:float
is patterned after an IEEE single-precision 32-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-10 lists some values of the xs:float
type.
Table B-10. Values of the xs:float type
XQuery makes a distinction between positive and negative zero values for the xs:float
type. 0
and −0
are considered to be equal but separate values.
The implementation has some flexibility regarding how to handle overflow or underflow occurs during arithmetic operations on xs:float
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.
Values of type xs:float
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:float
value 12.5E0
to xs:decimal
results in a value 12.5
whose type is xs:decimal
.
However, some xs:float
values are either too large or are otherwise not represented in the value spaces of xs:decimal
or xs:integer
. See the descriptions of these types for more information.
Additionally, some special cases apply when casting xs:double
values to xs:float
. Values that are too large to be represented by xs:float
are cast to INF
, values that are too small are cast to -INF
, and values that would cause underflow are cast to 0
.
Values of type xs:float
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 1000000 (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-10.
3.138.134.114