RE: Canonical representation of float/double and number of digits

At 3:59 PM +0000 2009-02-02, Michael Kay wrote:
>
>You might like to take into account that XSD 1.1 defines a canonical
>representation more precisely:
>
>http://www.w3.org/TR/xmlschema11-2/#f-doubleCanmap

But note also that this canonical mapping is but one of many allowed by
IEEE 754, and hence by Schema 1.1.  In any case, The canonical mappings
defined in the Schema 1.1 spec are there merely for the convenience of
anyone who wishes to use the Part 2 datatype specifications for other
purposes--and such a user can certainly specify a different canonical
mapping if it better suits his or her purposes.

In any case, note that the specific algorithm given in the reference
above may for some arguments require unbounded memory, and the same
results can be obtained in bounded memory by the more complicated
algorithm given in:

William D Clinger. How to Read Floating Point Numbers Accurately. In
    Proceedings of Conference on Programming Language Design and
    Implementation, pages 92-101. Available at:
    ftp://ftp.ccs.neu.edu/pub/people/will/howtoread.ps

(The unbounded memory is actually required in a sub-function,
http://www.w3.org/TR/xmlschema11-2/#f-floatPtRound .)

(Probably more than you ever wanted to know on the subject.  Sorry.
Feel free to ignore it.)
-- 
Dave Peterson
SGMLWorks!

davep@iit.edu

Received on Monday, 2 February 2009 16:23:13 UTC