This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: XPath number with 20 digits gives you a head ache
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: RE: [xsl] XPath number with 20 digits gives you a head ache
- From: "Michael Kay" <mhkay at iclway dot co dot uk>
- Date: Thu, 25 Jan 2001 10:25:06 -0000
- Reply-To: xsl-list at lists dot mulberrytech dot com
> Simple XPath question regarding string to number conversions. Should
>
> <xsl:value-of select="number(string('92125374252539897737'))" />
>
> return
>
> 92125374252539897737
>
> since most processors return
>
> 92125374252539900000
>
> which is not what one would want. Is this XPath spec or XSLT
> implementation related issue?
The spec requires IEEE 754 double-precision floating point arithmetic, which
is about 17 digits of precision. The rules are very strict and a processor
isn't allowed to give you greater precision even if it wants to, nor is it
allowed to "optimize out" the conversion of a string to a number and then
back to a string.
I hesitate to assert that the above is actually correct, but if you're
getting it from several processors then the chances are that it is.
Incidentally calling the string() function on a string literal seems rather
superfluous!
Mike Kay
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list