Re: Fastcode RoundTo

From: John Herbster (herb-sci1_AT_sbcglobal.net)
Date: 06/16/04


Date: Wed, 16 Jun 2004 13:34:12 -0500


"Dennis" <marianndkc@home3.gvdnet.dk> wrote
> What will your RoundTo function round (1.245, -2) to?

To avoid conflict with Math.RoundTo, I would not make a
function with that name.

The rounding routines in RoundToXReplacement_3c would do
the following rounding based on the control parameter (drHalfEven
which is the same as "bankers" would be the default):
  1.24 drHalfEven, {Round to nearest else to even digit. a.k.a Bankers}
  1.25 drHalfOdd, {Round to nearest else to odd digit. }
  1.25 drHalfPos, {Round to nearest else toward positive. }
  1.24 drHalfNeg, {Round to nearest else toward negative. }
  1.24 drHalfDown, {Round to nearest else toward zero. }
  1.25 drHalfUp, {Round to nearest else away from zero. }
  1.24 drRndNeg, {Round toward negative. a.k.a. Floor}
  1.25 drRndPos, {Round toward positive. a.k.a. Ceil }
  1.24 drRndDown, {Round toward zero. a.k.a. Trunc}
  1.25 drRndUp); {Round away from zero.}
Where it is understood that 1.24 would actually be the closest
representable number to that value. The 1.25, of course, being 5/(2^2)
can be exactly represented.

Regards, JohnH



Relevant Pages

  • Re: Fastcode RoundTo
    ... The rounding control could be like the following: ... {Round to nearest else to even digit. ... drHalfOdd, {Round to nearest else to odd digit. ...
    (borland.public.delphi.language.basm)
  • Re: RoundEx without Bankers rounding
    ... (drNone, {No rounding.} drHalfEven, {Round to nearest else to even digit. ... a.k.a Bankers} drHalfOdd, {Round to nearest else to odd digit. ...
    (borland.public.delphi.language.basm)
  • Re: Win32Forth & negative zero
    ... >>>Round to nearest/even is not necessarily better than others. ... nearest with even tie breakers "IEEE rounding", ... has four rounding modes, labeled in C99 as FE_TONEAREST, ... In particular C99, which I think is getting it right, and ought ...
    (comp.lang.forth)
  • RE: Rounding to nearest .00 or .50
    ... Then set your textbox control source and/or calculated query field to the ... > a course by dividing the total number of minutes of course instruction by 60 ... > but I need it to round to the nearest .00 which, ...
    (microsoft.public.access.forms)
  • Re: Hillary Clinton Gives Driving Advice
    ... would have to do would be to round to the nearest $0.1 instead. ... The gov't has tried that on the one with issuing the dollar coin (the ... "When you can't afford the gas to drive to the job ...
    (rec.autos.driving)