Lee Jenkins wrote:
willem wrote:
Benchmark results from :
http://shootout.alioth.debian.org/gp4/benchmark.php?test=sumcol&lang=all#about
--------------------------------------------------------------------------------
To me, it looks like FreePascal is ranking up there almost every test.
I don't understand the post. Can you clarify?
Here is the method being called. As of now, I have changed both the Currency
types to Double and everything works. Just changed it back to Currency here for
the list's benefit.
function TLevy.CalculateLevy( AmountToLevy: Currency) : Currency;
var
lResult: Currency;
begin
result := 0;
lResult := AmountToLevy * FLevyValue;
result := self.GetRoundedValue(FRoundingType, lResult);
end;
function TLevy.GetRoundedValue( ARoundType: TLevyRounding;AAmount: Currency
) : Currency;
begin
case ARoundType of
lrRndDownBy01: result := Double(Floor(100 * AAmount) / 100);
lrRndUpBy01: result := Double(Ceil(100 * AAmount) / 100);
lrRndDownBy05: result := Double(Floor(20 * AAmount) / 20);
lrRndUpBy05: Result := Double(Ceil(20 * AAmount) / 20);
lrRnddownBy25: result := Double(Floor(4 * AAmount) / 4);
lrRndUpBy25: result := Double(Ceil(4 * AAmount) / 4);
lrBankers: result := Round(AAmount);
end;
end;
The method gets called from here, in this test case.
procedure TTestLevy.LevyCalculate;
var
lLevy: TLevy;
lAmount: Currency;
ToLevy: Currency;
begin
// Note: This is not a permanent test case. More extensive
// testing will be here. Just a few simple test for now.
// Lee Jenkins, 12/25/2007
lLevy := TLevy.CreateNew('','');
try
// test round .25
ToLevy := 25.00;
lLevy.LevyType := ltTax;
lLevy.LevyValue := 0.05;
lLevy.RoundingType := lrRndUpBy25;
lAmount := lLevy.CalculateLevy(ToLevy);
AssertTrue('RoundDown did not calculate correctly', lAmount = 1.25);
// test round down to .05
ToLevy := 15.35;
lLevy.RoundingType := lrRndDownBy05;
lLevy.LevyValue := 0.07;
lAmount := lLevy.CalculateLevy(ToLevy);
AssertTrue('RoundUp did not work correctly', lAmount = 1.05);
// Test round up to .05
ToLevy := 15.35;
lLevy.RoundingType := lrRndUpBy05;
lLevy.LevyValue := 0.07;
lAmount := lLevy.CalculateLevy(ToLevy);
AssertTrue('Round Down did not work.', lAmount = 1.10);
finally;
lLevy.free;
end;
end;
--
Warm Regards,
Lee
"If I don't see you around here, I'll see you around, hear?"
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives