https://bz.apache.org/bugzilla/show_bug.cgi?id=66047
Bug ID: 66047
Summary: Rounding issue in MROUND due to 1897066
Product: POI
Version: 5.2.1-FINAL
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P2
Component: SS Common
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: ---
Created attachment 38271
--> https://bz.apache.org/bugzilla/attachment.cgi?id=38271&action=edit
MRound BigDecimal implementation
Hi
I noticed a rounding difference after upgrading to poi and tracked the change
back to version 5.2.1
https://svn.apache.org/viewvc?view=revision&revision=1897066.
I do acknowledge the new calculation as more correct, but it creates a follow
up problem when using the MROUND formula.
Consider the following example: MROUND(0.79*7.5;0.05).
In Excel, the result is 5.95. In POI 5.2.1 the result ist 5.90.
This happens because earlier POI version evaluated 0.79*7.5 to
5.925000000000001. The new BigDecimal based calculation ist instead (correctly)
evaluating this to 5.925.
The MRound implementation is rounding this down, where as before it was
rounding up:
> result = multiple * Math.round( number / multiple );
In my opinion, it would make sense to replace this implementation with a
BigDecimal version and the HALF_UP rounding mode (see patch).
Thanks!
--
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]