Re: What is RoundToEx?
- From: "Dennis" <marianndkc@xxxxxxxxxxxxxxx>
- Date: Thu, 27 Dec 2007 17:30:46 +0100
Hi John
You suggest we use this algorithm
Result := Round(Input*100)/100;
How does that compare to the one we use?
Result := Round(AValue / LFactor) * LFactor;
And what are the differences regarding precision?
Best regards
Dennis Kjaer Christensen
function RoundToEX_Ref(const AValue: Extended; const ADigit:
TRoundToEXRangeExtended): Extended;
var
LFactor: Extended;
CW8087 : Word;
begin
CW8087 := Get8087CW;
if (ADigit < Low(TRoundToEXRangeExtended)) or (ADigit >
High(TRoundToEXRangeExtended)) then
raise Exception.Create('ADigit out of range');
try
SetPrecisionMode(pmExtended);
SetRoundMode(rmNearest);
LFactor := IntPower(10, ADigit);
Result := Round(AValue / LFactor) * LFactor;
finally
Set8087CW(CW8087);
end;
end;
.
- Follow-Ups:
- Re: What is RoundToEx?
- From: Q Correll
- Re: What is RoundToEx?
- From: John Herbster
- Re: What is RoundToEx?
- References:
- What is RoundToEx?
- From: John Herbster
- Re: What is RoundToEx?
- From: Dennis
- Re: What is RoundToEx?
- From: John Herbster
- Re: What is RoundToEx?
- From: Dennis
- What is RoundToEx?
- Prev by Date: Re: What is RoundToEx?
- Next by Date: Re: What is RoundToEx?
- Previous by thread: Re: What is RoundToEx?
- Next by thread: Re: What is RoundToEx?
- Index(es):
Relevant Pages
|
Loading