Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Rounding forward
riplin@Azonic.co.nz (Richard) wrote

> I have done systems that carry the rounding forward.  That is when the
> first number is rounded the difference is added to the next number
> before that is rounded (or truncated, as preferred).  This ensures
> that the total is always correct rather than being randomly incorrect
> by a small amount.

To clarify how this works (it does NOT do 'intermediate rounding')
here is an example.

Suppose we have a list of dollar.cent values, say branch sales totals,
that add up to a certain figure that is the total sales.  The account
wants his report to be in thousands of dollars only.  We could round
each branch total and the total sales separately, but then it might
not add up to the rounded total sales.  We could round each and add
these to give a new total, but it might not be the same number as the
total sales.

Branch sales       Rounded separately      Rounded and added
1      5623.55               6                      6
2      6700.22               7                      7
3      1512.63               2                      2
4      1622.00               2                      2
------------------------------------------------
total  15458.40              15                     17

The accountant won't like columns that don't add up, and also don't
like totals that are wrong.

By rounding each branch figure there is a rounding error.  In the
example above this has been discarded so the difference between to 15
and the 17 is the accumulation of rounding errors (due to rather
contrived values).

To cater for these errors and arrive at the best (for the accountant)
report the error from one rounding is added to the next number before
that is rounded.  The accumulated rounding error is then less than .5
for the column.

(view with a fixed font please)

Branch sales   carry forward   adjusted      Rounded
5623.55           0.00        5623.55        6
6700.22       - 376.45        6323.77        6
1512.63         323.77        1836.40        2
1622.00       - 163.60        1458.40        1
458.40
--------                                   -----
15458.40                                     15

The column now adds up correctly and gives the correct total.  The
accumulated rounding error for the column is exactly the rounding
error on the total.

For completeness you would store this away until the next month and
use it as the initial 'carry forward' so that at the end of the year
the 12 monthly reports totals will actually add up to the annual total
sales rounded figure.

Report this thread to moderator Post Follow-up to this message
Old Post
Richard
08-26-04 08:55 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Cobol archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:48 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.