Re: FastCode RoundToEx
- From: "Dennis" <marianndkc@xxxxxxxxxxxxxxx>
- Date: Sat, 29 Dec 2007 16:22:11 +0100
Hi
There is a bug in RoundTo_JFH which confused me. Now it makes more sense to
me.
Type
tRoundToRange27 = -27 .. +27;
{ Beyond above range, extended cannot represent exact multiplier.}
function RoundTo_JFH
(const aValue: Extended;
const NbrDecFractDigits: tRoundToRange27): Extended;
var LFactor: Extended; CW8087 : Word;
begin
CW8087 := Get8087CW;
if (NbrDecFractDigits < Low(tRoundToRange27)) or
(NbrDecFractDigits > High(tRoundToRange27))
then raise Exception.Create('NbrDecFractDigits out of range');
try
Set8087CW($1332);
{ i.e. extended precision and bankers rounding on a binary basis }
LFactor := IntPower(10, NbrDecFractDigits); ///<----------- LFactor
:= IntPower(10, -NbrDecFractDigits);
Result := Round(aValue*LFactor)/LFactor;
finally
Set8087CW(CW8087);
end;
end;
Best regards
Dennis Kjaer Christensen
.
- Follow-Ups:
- Re: FastCode RoundToEx
- From: John Herbster
- Re: FastCode RoundToEx
- References:
- FastCode RoundToEx
- From: Dennis
- Re: FastCode RoundToEx
- From: Dennis
- Re: FastCode RoundToEx
- From: John Herbster
- FastCode RoundToEx
- Prev by Date: Re: FastCode Reference Compilers
- Next by Date: Re: FastCode RoundToEx
- Previous by thread: Re: FastCode RoundToEx
- Next by thread: Re: FastCode RoundToEx
- Index(es):