Re: Fastcode RoundTo B&V 0.1
From: John Herbster (herb-sci1_AT_sbcglobal.net)
Date: 06/03/04
- Previous message: Dennis: "Re: Fastcode Move"
- In reply to: John Herbster: "Re: Fastcode RoundTo B&V 0.1"
- Next in thread: John Herbster: "Re: Fastcode RoundTo B&V 0.1"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: Dennis: "Re: Fastcode Move"
- In reply to: John Herbster: "Re: Fastcode RoundTo B&V 0.1"
- Next in thread: John Herbster: "Re: Fastcode RoundTo B&V 0.1"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|