
16.08.2011, 13:24
|
 |
Let Me Show You
|
|
Регистрация: 30.04.2010
Адрес: Северодвинск
Сообщения: 5,426
Версия Delphi: 7, XE5
Репутация: 59586
|
|
Ildar-tsr:
function IntPower(const Base: Extended; const Exponent: Integer): Extended;
Код:
unit Math;
function RoundTo(const AValue: Double; const ADigit: TRoundToRange): Double;
var
LFactor: Double;
begin
LFactor := IntPower(10, ADigit);
Result := Round(AValue / LFactor) * LFactor;
end;
function SimpleRoundTo(const AValue: Double; const ADigit: TRoundToRange = -2): Double;
var
LFactor: Double;
begin
LFactor := IntPower(10, ADigit);
Result := Trunc((AValue / LFactor) + 0.5) * LFactor;
end;
--
Код:
uses
UMathServices,
Memo1.Lines.Add(ulSub('212.53', '212.49'));
Memo1.Lines.Add(ulSub('212.053', '212.049'));
Memo1.Lines.Add(ulSub('212.4556565', '212.343676676'));
__________________
Пишу программы за еду.
__________________
|