You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Bhuvan Mohan <bh...@in.fiorano.com> on 2014/11/28 11:30:09 UTC

Issue with double in FuncSum

Hi Everyone,

We are using xalan 2.7.0 in our product. I recently faced an issue which 
I found exists in Java Double.
In nodeset summation using double the output is not precise

Ref: 
http://stackoverflow.com/questions/5257166/java-floats-and-doubles-how-to-avoid-that-0-0-0-1-0-1-0-9000001

In class org.apache.xpath.functions.FuncSum#execute, double is being 
used. It all works perfectly fine but when I debugged the source I found 
the problem occurs after summation is done in the line after returning 
from toDouble() in

sum += s.toDouble();

when I did a test on a seperate Java sample I faced a similar result. It 
appears that using BigInteger could help resolve the problem.

Thanks & Regards,
Bhuvan Rawal