Ildar-tsr:
function
IntPower(const Base: Extended; const Exponent: Integer): Extended;
Код:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | 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 ;
|
--
Код:
1 2 3 4 5 6 | 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' ));
|