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

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


The expression "string(-0.0)" incorrectly transformed to -0, but it 
should be 0 according to W3C specification: 

The webrev with fix and the test case:

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;


More information about the core-libs-dev mailing list