RE: Representation of floating point values.

>Of the three possible options:

>1. Map to the largest finite double
>2. Map to +Infinity
>3. Raise an error

>option 1 seems the least desirable.

>Java does (2).


According to 

http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#
230798
 
Java uses option 3, doesn't it?  Quote:

" A compile-time error occurs if a nonzero floating-point literal is too
large, so that on rounded conversion to its internal representation it
becomes an IEEE 754 infinity. A program can represent infinities without
producing a compile-time error by using constant expressions such as
1f/0f or -1d/0d or by using the predefined constants POSITIVE_INFINITY
and NEGATIVE_INFINITY of the classes Float and Double."

Actually, this document has the same bug, as a "rounded conversion" can
not be infinity.

I would imagine that raising an error (not a valid representation of an 
Floating point literal) is the most desirable outcome.  If somebody
wanted an INF, there are explicit way to construct it.

Daniel;

 

> -----Original Message-----
> From: w3c-xml-query-wg-request@w3.org 
> [mailto:w3c-xml-query-wg-request@w3.org] On Behalf Of Daniel Engovatov
> Sent: 07 March 2005 21:43
> To: www-xml-schema-comments@w3.org
> Cc: w3c-xml-query-wg@w3.org
> Subject: Representation of floating point values.
> 
> 
> During our recent XQuery working group meeting we have closed an issue
> regarding what should be done if a numerical literal representing a
> float or double value is out of range for IEEE 754 values 
> (positive and
> negative overflow or underflow).
> 
> --------
> RESOLUTION: Too big float/double values.
> http://lists.w3.org/Archives/Member/w3c-xml-query-wg/2005Feb/0084.html
> is rejected. No action required to 3.1.1. Schema says that one should
> map to the largest float or double value.
> --------
> 
> It does seem to me that this is an unfortunate choice in the Schema to
> just map a non-representable number into another number.  Probably,
> other options should be allowed for an implementation, such raising an
> error and mapping to +/- INF.
> 
> Sincerely,
> 
> Daniel Engovatov.   
> 
> 
> 
> 

Received on Monday, 7 March 2005 22:22:45 UTC