The scheme John McKown describes is called Gaussian roundoff. It has the merits that it is familiar and easy to implement. It is not unbiased, and it is not always the best or even a particularly good rounding scheme to use.
Rounding is, in general, a much more complex process than many people suppose it to be, and the standards organizations have been busy discussing it and and issuing directives about how to do it for many years. There is an excellent b ut technically demanding discussion of the issues involved and what has been implemented for BFP and DFP in section 9-13 of the PrOp. It is almost always unwise to implement a rounding scheme implicitly in open code. It should be put into a closed function. This is because many insurance and utility regulators specify how 'penny breakage' is to be implemented in computer applications for their jurisdictions. These rules differ significantly from one jurisdiction to another, and combing through code to find all of the places where an implicitit or explicit rounding operation has been performed is tedious and error-prone. For a truly unbiased scheme, which is likely be required only in some scientific and engineering calculations adn where the public interest requires no bias, Forsythe rounding---named afterthe American mathematician, computer pioneer, and founder of Stanford's Computer Science Department George Forsythe (1917-1972)---is used. One adds the output r, 0 <= r <= 1, of a high-quality rectangular pseudo-random number generator to the value to be rounded and truncates. If, say, 1.2 is to be rounded to an integer TRUNC(1.2 + r, 1) yields 1 with probability 0.8 and 2 with probability 0.2. John Gilmore, Ashland, MA 01721 - USA ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN
