[xslt] floor(), ceiling(), and round() functions and negative values



Hi,

Another bug report files against the Debian package of libxslt is about
the floor(), ceiling(), and round() functions and negative values.

given the XML file

    <?xml version="1.0"?>
    <testdata>
	<datum val="-0"     f="-0" c="-0" r="-0"/>
	<datum val="-0.4"   f="-1" c="-0" r="-0"/>
	<datum val="-0.5"   f="-1" c="-0" r="-0"/>
	<datum val="-0.6"   f="-1" c="-0" r="-1"/>
    </testdata>

and the XSLT stylesheet

    <?xml version="1.0"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
	<xsl:output method="text"/>
	<xsl:variable name="nl"><xsl:text>
    </xsl:text></xsl:variable>
	<xsl:template match="/">
	    <xsl:for-each select="//datum">
		<xsl:value-of select="concat('floor(', @val, ')   = ', floor(@val), ' (should be ', @f, ')', $nl)"/>
		<xsl:value-of select="concat('ceiling(', @val, ') = ', ceiling(@val), ' (should be ', @c, ')', $nl)"/>
		<xsl:value-of select="concat('round(', @val, ')   = ', round(@val), ' (should be ', @r, ')', $nl, $nl)"/>
	    </xsl:for-each>
	</xsl:template>
    </xsl:stylesheet>

the following output is generated with libxslt v1.0.27:

    floor(-0)   = 0 (should be -0)
    ceiling(-0) = 0 (should be -0)
    round(-0)   = 0 (should be -0)

    floor(-0.4)   = -1 (should be -1)
    ceiling(-0.4) = 0 (should be -0)
    round(-0.4)   = 0 (should be -0)

    floor(-0.5)   = -1 (should be -1)
    ceiling(-0.5) = 0 (should be -0)
    round(-0.5)   = 0 (should be -0)

    floor(-0.6)   = -1 (should be -1)
    ceiling(-0.6) = 0 (should be -0)
    round(-0.6)   = -1 (should be -1)

while sablotron v0.97 generates

    floor(-0)   = -0 (should be -0)
    ceiling(-0) = -0 (should be -0)
    round(-0)   = 0 (should be -0)

    floor(-0.4)   = -1 (should be -1)
    ceiling(-0.4) = -0 (should be -0)
    round(-0.4)   = 0 (should be -0)

    floor(-0.5)   = -1 (should be -1)
    ceiling(-0.5) = -0 (should be -0)
    round(-0.5)   = 0 (should be -0)

    floor(-0.6)   = -1 (should be -1)
    ceiling(-0.6) = -0 (should be -0)
    round(-0.6)   = -1 (should be -1)

and xalan v1.2 produces

    floor(-0)   = 0 (should be -0)
    ceiling(-0) = 0 (should be -0)
    round(-0)   = 0 (should be -0)

    floor(-0.4)   = -1 (should be -1)
    ceiling(-0.4) = -0 (should be -0)
    round(-0.4)   = 0 (should be -0)

    floor(-0.5)   = -1 (should be -1)
    ceiling(-0.5) = -0 (should be -0)
    round(-0.5)   = 0 (should be -0)

    floor(-0.6)   = -1 (should be -1)
    ceiling(-0.6) = -0 (should be -0)
    round(-0.6)   = -1 (should be -1)

None of them gets it completely right, though.

Are these indeed bugs?  If so, I'll file an official bug report.

Thanks,
Ardo
-- 
Ardo van Rangelrooij
home email: ardo@debian.org
home page:  http://people.debian.org/~ardo
GnuPG fp:   3B 1F 21 72 00 5C 3A 73  7F 72 DF D9 90 78 47 F9
_______________________________________________
xslt mailing list, project page http://xmlsoft.org/XSLT/
xslt@gnome.org
http://mail.gnome.org/mailman/listinfo/xslt



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]