Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: mathematical rounding...

From: rpgwriter::yahoo::com at: 6-Nov-2001 14:47

--- Gregg Irwin <[greggirwin--mindspring--com]> wrote:
> Hi Alan, > > << There are several accepted methods of rounding. > One version for rounding > from 0.5 says to round up if the number to the left > of the decimal is even, > and truncate if it is odd. The purpose (hope) is to > randomize the error > so any statistics behave better. >> > > Right. That's what I meant by statistical rounding.
Right. Other schemes try to preserve different features. Examples Round even (or odd) guarantees that: 1) if integer-parts are evenly distributed, rounding bias cancels. 2) round(-x) equals -round(x) Round toward (or away from) zero guarantees that: 1) round(-x) equals -round(x) 2) if (sign(x)=sign(x+1)) round(x)+1 = round(x+1) Round greater (or less) guarantees that: 1) round(x)+1 = round(x+1) This isn't exhaustive, merely illustrative. In different applications, different behaviors may be most desirable.