[#9371] - Rounding mode is not adjustable

Category:
Bug report
Priority:
Normal
Status:
Confirmed
Project: Severity:
Minor
Resolution:
Open
Component: Reproducibility:
Always
Assigned to:
0

Rounding of numbers should be easy adjustable. This is required to comply with financial requirements. The default rounding mode used rounds 0.5 down which is contrary to what most people expect. Legal code might dictate what rounding mode to use. There could be more than one rounding mode in any single report.

Today there exist two workarounds:
1) new BigDecimal($F{....}).setScale(2, BigDecimal.ROUND_HALF_UP)
This works but is very ugly and hard to maintain and not discoverable for a report designer.

2) specify a custom FormatFactory (via REPORT_FORMAT_FACTORY parameter)
Requires custom code. Not achievable for a report designer.

At least two changes are needed:
A) a report wide default rounding mode
B) a per text field override

The attached report shows the current (unexpected) rounding behavior.

AttachmentSize
Binary Data roundingerror.jrxml2.42 KB
v6.3.1
JasperReports
thomas_33's picture
Joined: Mar 21 2017 - 3:12am
Last seen: 4 years 7 months ago

2 Comments:

#1
  • Status:New» Confirmed
#2

The problem is even worse: The default rounding mode is set to HALF_EVEN ( https://docs.oracle.com/javase/8/docs/api/java/math/RoundingMode.html#HA... ), meaning:

0.4 -> 0
0.5 -> 0
0.6 -> 1
1.4 -> 1
1.5 -> 2
1.6 -> 2
2.5 -> 2
3.5 -> 4
4.5 -> 4
...

This rounding mode is totally unusual (at least in Germany) and leads to unexpected results.
From my point of view UP, DOWN and HALF_UP are more usual rounding modes.

AttachmentSize
Binary Data roundingmodetest.jrxml3.79 KB
Feedback
randomness