- From: Michael Kay <mike@saxonica.com>
- Date: Thu, 2 Jun 2016 12:12:15 +0100
- To: Tim Mills <tim@cbcl.co.uk>
- Cc: public-xsl-query@w3.org, Andrew Coleman <andrew_coleman@uk.ibm.com>
> > 1 div 3 cast as xs:float has string value 0.33333334 and precise decimal value 0.33333 33432 67440 79589 84375. I was a little surprised by this: since the mantissa/significand of an xs:float value is less than 2^24 (16777216), why should the precise decimal value of an xs:float occupy 25 digits? The answer is of course that although there are only 16777216 possible values of the mantissa, these values are thinly spread out among the space of xs:decimal values. One observation I would make is that although the spec describes an algorithm whereby numbers are expressed as exact decimal values, that doesn't prescribe an implementation. I can imagine algorithms that compare an xs:float and an xs:decimal for "precise equality" without converting the xs:float to an arbitrary-precision decimal. Furthermore, even if the comparison is done by converting to an arbitrary precision decimal representation, this doesn't necessarily require use of a library with support for arithmetic on arbitrary precision decimals. The only operations that the arbitrary-precision decimal representation needs to support are conversion from float, double, and decimal, and equality comparison. Michael Kay Saxonica
Received on Thursday, 2 June 2016 11:13:03 UTC