RFR 8015978: Incorrect transformation of XPath expression "string(-0)"

Aleksej Efimov aleksej.efimov at oracle.com
Thu Jun 6 17:10:37 UTC 2013


Hi,

The expression "string(-0.0)" incorrectly transformed to -0, but it 
should be 0 according to W3C specification: 
http://www.w3.org/TR/xpath/#function-string

The webrev with fix and the test case:
http://cr.openjdk.java.net/~dmeetry/8015978/webrev.1/ 
<http://cr.openjdk.java.net/%7Edmeetry/8015978/webrev.1/>

There is another way of disabling the -0 result. In current webrev the 
minus zero is processed with such code:

+	
+	    //Check for -0.0 and convert it to 0.0
+	    if (new Double(d).equals(new Double(-0.0))
+		d=0.0;

We can make the replace of -0 -> 0 faster (I think but didn't tested it) 
with the following code, but it looks strange and will work both for 0 
and -0:

+	    //Check for -0.0 and convert it to 0.0
+	    if (d == 0.0)
+		d=0.0;

-Aleksej



More information about the core-libs-dev mailing list