D7
ChatGPT sagt SimpleRoundTo für D7:
Zitat:
Ja, Delphi 7 enthält bereits die
Unit Math, jedoch die Funktion SimpleRoundTo wurde erst später in Delphi 2006 (Borland Developer Studio 2006) eingeführt.
ungetestet:
Delphi-Quellcode:
// Beispielimplementierung von SimpleRoundTo in Delphi 7
function SimpleRoundTo(const AValue: Extended; const ADigit: Integer): Extended;
var
Factor: Extended;
begin
Factor := IntPower(10, ADigit);
Result := Round(AValue * Factor) / Factor;
end;
Original D12:
Delphi-Quellcode:
function SimpleRoundTo(const AValue: Extended; const ADigit: TRoundToRange = -2): Extended;
var
LFactor: Extended;
begin
LFactor := IntPower(10.0, ADigit);
if AValue < 0 then
Result := Int((AValue / LFactor) - 0.5) * LFactor
else
Result := Int((AValue / LFactor) + 0.5) * LFactor;
end;