|
Rounding numbers is necessary when you need to convert a number of greater precision to a number of lesser precision. Many of the Unanet reports will round the resulting values to display in a typical currency format for example.
Whenever rounding is employed, you may have an opportunity to encounter discrepancies between similar values, displayed at varying levels of detail, across reports. Such may be the case when comparing similar data between a Summary level report and a Detail level report.
For example, you may run a Summary report for a user which will aggregate a number of hours, multiply that sum of hours against the user's hourly cost rate, and then round the resulting value. In this case, only the final result is rounded.
When running a Detail report for the same user and the same selection criteria, each resulting detail line item displayed on the report has the potential to be rounded. On these Detail reports, sub-total and total lines will typically reflect a summary of the un-rounded intermediate details, having the final sub-total or total value rounded. This may result in the numbers on the particular report 'not adding up' to the displayed totals (which should be more accurate than a sum of the displayed/rounded detail line numbers).
When you add rounded values together, always rounding .5 in the same direction results in a bias that grows with the more numbers you add together. One way to minimize this bias is with a rounding method known as "banker's rounding".
With Bankers rounding, values below 0.5 go down and values above 0.5 go up. Values of exactly 0.5 go to the nearest even number. So 12.5 will be rounded down to 12 and a value of 13.5 will be rounded up to 14.
The justification for bankers rounding: consider how you would round the numbers 12.0 to 13.0 in steps of 0.1. There are 9 values that need to be rounded. Traditional rounding moves 5 of the 9 values up and 4 of the values down - always. This is biased (1/9 more up than down). The bankers rounding method is intended to even out this bias and result in a more accurate aggregate result.
Very specifically, within our reports, we use a java object called DecimalFormat to format the numbers that show up in the reports. By default, this formatter uses RoundingMode.HALF_EVEN to round numbers when necessary. Here is the description of the rounding method provided in Java documentation:
Rounding mode to round towards the "nearest neighbor" unless both neighbors are equidistant, in which case, round towards the even neighbor. Rounds up if the digit to the left of the discarded fraction is odd; rounds down if it's even. Note that this is the rounding mode that statistically minimizes cumulative error when applied repeatedly over a sequence of calculations. It is sometimes known as "Banker's rounding".
For more details regarding how amounts are rounded on Unanet invoices, check out the Auto-Correct Invoice Rounding option and the Invoice Rounding topic in our Knowledge Center.