|
@@ -182,6 +182,19 @@ begin
|
|
|
Result := CommonRoundTo(AValue, iTotalPriceDigit);
|
|
|
end;
|
|
|
|
|
|
+function GetTrueDigit(AValue: Double): Integer;
|
|
|
+var
|
|
|
+ sValue: string;
|
|
|
+ iPointPos: Integer;
|
|
|
+begin
|
|
|
+ sValue := FloatToStr(AValue);
|
|
|
+ iPointPos := Pos('.', sValue);
|
|
|
+ if iPointPos = 0 then
|
|
|
+ Result := 0
|
|
|
+ else
|
|
|
+ Result := -(Length(sValue) - iPointPos);
|
|
|
+end;
|
|
|
+
|
|
|
function CommonRoundTo(AValue: Double; ADigit: Integer; RoundMode: TRoundMode = rmNearest): Double;
|
|
|
var
|
|
|
X: Double;
|
|
@@ -204,7 +217,10 @@ begin
|
|
|
end;
|
|
|
P := @X;
|
|
|
CopyMemory(P, @Buf[0], SizeOf(X));
|
|
|
- Result := InnerRoundTo(X, ADigit, RoundMode);
|
|
|
+ if (ADigit > 0) then
|
|
|
+ Result := InnerRoundTo(X, Min(GetTrueDigit(AValue), ADigit), RoundMode)
|
|
|
+ else
|
|
|
+ Result := InnerRoundTo(X, Max(GetTrueDigit(AValue), ADigit), RoundMode);
|
|
|
end;
|
|
|
|
|
|
{Interface Control}
|