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

Re: Classic RW (was: Rounding errors
"Robert Wagner" <robert@wagner.net.yourmammaharvests> wrote in message
 news:o7b3j01nfgsr6b72q0h3hmnnn8kkejicqc@
4ax.com...
> On Sun, 29 Aug 2004 04:42:10 GMT, "William M. Klein"
> <wmklein@nospam.netcom.com> wrote:
> 
[snip] 
>
> How about the prize for Numerancy. If you don't understand that
> fixed-point numbers are integers, you're innumerate.

Mr Wagner, it is my understanding that fixed-point numbers are
scaled-integers, not mere integers, and that fixed-point numbers
consist of an integer value and an implied operator and integer
scale factor.

Perhaps I am innumerate, nonetheless, because I cannot count
the number of times you have introduced an inaccuaracy and
defended it as correct. <g>

Mr Wagner, your allegation was, as I recall, that COBOL
rounding was wrong because the sum of rounded numbers
was too high for a contrived sequence of numbers. This
cannot be the case because the COBOL rounding rule
applies to only single calculations not their sum.

The method I learned (and have not practiced since) was, as
I recall, 'Round to even numbers'. This may be implemented,
for positive numbers, (untested) as:

if (function rem (my-number 1) = 0.5
if (function mod (function integer (my-number) 2)) = 0
subtract 0.5 from my-number giving rounded-number
end-if
else
add 0 my-number giving rounded-number rounded
end-if

1.5+2.5+3.5+4.5=12 becomes
2+2+4+4=12

but 1.5+3.5+5.5+7.5=18 becomes
2+4+6+8=20

and 2.5+4.5+6.5+8.5=22 becomes
2+4+6+8=20

thus, as shown here, the accuracy of the sum of rounded
numbers depends upon the distribution, between even and
odd, of the integer part of the numbers. Furthermore, the
accuracy of the sum of rounded numbers also depends
on the distribution, relative to 0.5, of the fractional part.
The COBOL rounding rule does not define, nor control,
such distributions.

The point being that a rounding rule that applies to only
single calculations cannot, properly, be blamed for the
inaccuracy of the sum. This includes the rule 'Round to
even numbers'.




Report this thread to moderator Post Follow-up to this message
Old Post
Rick Smith
08-30-04 08:55 AM


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 06:34 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.