Error/Bug adding floating point numbers 2006-08-31 - By Daniel Thommes
Hello,
I think to have found a bug in Xalan-J 2.7.0 when adding floating point numbers:
My XML-File:
<?xml version="1.0" encoding="UTF-8"?> <values> <x>2.33</x> <y>2.001</y> </values>
My XSLT-File:
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/values"> <results> <sum> <xsl:value-of select="x + y"/> </sum> <diff> <xsl:value-of select="x - y"/> </diff> </results> </xsl:template> </xsl:stylesheet>
The result procuced by Xalan:
<?xml version="1.0" encoding="UTF-8"?> <results> <sum>4.3309999999999995</sum> <diff>0.3290000000000002</diff> </results>
I know, that the error is very small, but because in a later step I will round those numbers, it is likely that there will happen bigger errors thinking of worst case.
Any suggestions how to fix this problem? Do you think, I should open an issue for this?
Greetings
Daniel
--
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
|
|