GNOME Bugzilla – Bug 72150
numbers should be represented as 64-bit real
Last modified: 2009-08-15 18:40:50 UTC
Daniel, Here is a problem with format-number. In the following example: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <xsl:value-of select="format-number(100000000000,'#,##0.##')"/>| <xsl:value-of select="format-number(2147483647,'#,##0.##')"/>| <xsl:value-of select="format-number(2147483648,'#,##0.##')"/>| <xsl:value-of select="format-number(4294967296,'#,##0.##')"/>| </xsl:template> </xsl:stylesheet> I would expect the following output: 100,000,000,000| 2,147,483,647| 2,147,483,648| 4,294,967,296| Instead the latest version (1.0.12) gives: 1,215,752,192| 2,147,483,647| -2,147,483,648| 0| It's clear from the results that numbers are implemented as longs in libXSLT (or at least they are processed in format-number as longs). According to the XSLT standard, which makes reference to the XPATH Number definition: "A number can have any double-precision 64-bit format IEEE 754 value [IEEE 754]." (see http://www.w3.org/TR/xpath#numbers) TIA Jon Zaid P.S. Sorry I didn't get back to you about the other decimal-format bug (68759) that you fixed. The results are now correct. P.P.S. Keep up the excellent work and thanks for the great product!
Hum, numbers are represented as 64 bits real. But I had a serious problem with gcc on the XPath parser at some points (explanations at http://veillard.com/gcc.bug , enjoy !) and as a result when compiling the XPath parser with gcc I was moving the temporary value to an int to avoid the problem. I changed the way to deal with this problem and it now seems to work as expected: paphio:~/XSLT/tests/general -> xsltproc bug-75.xsl ../docs/bug-75.xml <?xml version="1.0"?> 100,000,000,000| 2,147,483,647| 2,147,483,648| 4,294,967,296| paphio:~/XSLT/tests/general -> Patch in CVS (against libxml2): http://cvs.gnome.org/bonsai/cvsquery.cgi?module=gnome-xml&branch=HEAD&branchtype=match&dir=gnome-xml&file=&filetype=match&who=veillard&whotype=match&sortby=Date&hours=&date=explicit&mindate=03%2F07%2F02+03%3A35&maxdate=03%2F07%2F02+03%3A37&cvsroot=%2Fcvs%2Fgnome thanks for the report, Daniel
This should be fixed in the recent releases, thanks, Daniel