Re: Fastcode RoundTo B&V 0.1

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

  • Next message: John O'Harrow: "Re: Fastcode Move"
    Date: Thu, 3 Jun 2004 07:00:14 -0500
    
    

    I need help from other programmers in deciding the following question:

    Should the name and sign convention for number decimal fraction "Digits"
    be changed?

    Should the type of the "Digits" parameter TRoundToRange should be -27 ..
    +27 or just "integer"?

    Should other names be changed?

    Here are the usuages:

      TRoundToRange = -37 .. 37; {Copied from D7's Math unit}

      tDecimalRoundingCtrl = {Defined rounding methods} {From
    DecimalRounding_JH0}
       (drNone, {No rounding.}
        drHalfEven, {Round to nearest else to even digit. a.k.a Bankers}
        drHalfOdd, {Round to nearest else to odd digit. }
        drHalfPos, {Round to nearest else toward positive. }
        drHalfNeg, {Round to nearest else toward negative. }
        drHalfDown, {Round to nearest else toward zero. }
        drHalfUp, {Round to nearest else away from zero. }
        drRndNeg, {Round toward negative. a.k.a. Floor}
        drRndPos, {Round toward positive. a.k.a. Ceil }
        drRndDown, {Round toward zero. a.k.a. Trunc}
        drRndUp); {Round away from zero.}

    function RoundExtTo (
        const Value: extended;
        const Digits: TRoundToRange; {Presently -2 for cents.}
        const Ctrl: tDecimalRoundingCtrl = drHalfEven;
        const SafetyFactor: double = 2)
        : extended;

    function RoundDblTo (
        const Value: double; {This might be type extended}
        const Digits: TRoundToRange; {Presently -2 for cents.}
        const Ctrl: tDecimalRoundingCtrl = drHalfEven;
        const SafetyFactor: double = 2)
        : extended;

    function RoundSglTo (
        const Value: single; {This might be type extended}
        const Digits: TRoundToRange; {Presently -2 for cents.}
        const Ctrl: tDecimalRoundingCtrl = drHalfEven;
        const SafetyFactor: double = 2)
        : extended;

    Function DecimalRound(
        const Value: extended;
        const Digits: integer; {Presently +2 for cents.}
        const MaxRelErr: double;
        const Ctrl: tDecimalRoundingCtrl = drHalfEven)
        : extended;
    { The DecimalRounding function is for doing the best possible job of
    rounding
      floating binary point numbers to the specified (Digits) number of
    decimal
      fraction digits. MaxRelErr is the maximum relative error that will
    allowed
      when determining when to apply the rounding rule. This is the
    workhorse
      function called by the other rounding functions above. }

    Thanks for any suggestions, JohnH


  • Next message: John O'Harrow: "Re: Fastcode Move"

    Relevant Pages

    • Re: Handicap calculator Excel question
      ... excel does not round to the nearest tenth, but rather drops the digits ... excel sheet because I am letting it round it off. ...
      (rec.sport.golf)
    • Re: Round up an average
      ... You have to tell it how many digits to round to For example, to roundup to ... the nearest whole number: ...
      (microsoft.public.excel.misc)
    • Re: Rounding to non-Integers
      ... round to the nearest .1, since that is as fine as my data goes. ... Binary floating point numbers are not able to express 0.1 ... digits, but the ones after that are not going to be 0. ...
      (comp.soft-sys.matlab)
    • Re: XQ and ->Qpi bug on large X
      ... you shouldn't be rounding to only two digits ... I am trying to make a similar point here about rounding; ... and round it, ... prior to using the input values in calculations. ...
      (comp.sys.hp48)
    • Re: Decimall Float Question
      ... the number other than to round the decimal part. ... 'bankers rounding' to the nearest even number is not required). ... the FAQ code includes having a variable number of digits after ... // Convert number to string and split ... ...
      (comp.lang.javascript)

    Loading