https://issues.apache.org/bugzilla/show_bug.cgi?id=51339
--- Comment #5 from Michal <[email protected]> 2011-06-08 18:13:55 UTC --- Thanks for your comments. So im doing an assertion in following way. I created a visual basic script which simply do the CSV dump. Values in csv are the same as in excel. Then i load this cvs in java and simply assert it with values from POI. I debug it and when poi read excel before calculation this values does not have any floating points). I can't use DataFormatter for wrong calculated value it wont do ,62 from ,61. I also found a problwm with round function. Specialy round half up. I saw that POI is using MathX.round method for rounding. Here is a code: public static double round(double n, int p) { double retval; if (Double.isNaN(n) || Double.isInfinite(n)) { retval = Double.NaN; } else { if (p != 0) { double temp = Math.pow(10, p); retval = Math.round(n*temp)/temp; } else { retval = Math.round(n); } } return retval; } Unfortunetly we have different results in excel and POI when we have 5 in the end. Take a look at following examples: round(2162.615, 2) -> 2162.61 round(262.615, 2) -> 262.62 In first case round down in second round up. Excel always do a round up. To fix it we can change implementation of this function to: BigDecimal temp = new BigDecimal(String.valueOf(n)).setScale(p, RoundingMode.HALF_UP); retval = temp .doubleValue(); -- Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
