Code Comments
Programming Forum and web based access to our favorite programming groups."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'.
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.