function RoundStr(Zn: Real; kol_zn: Integer): Real;
var
snl, s, s0, s1, s2: string;
n, n1: Real;
nn, i: Integer;
begin
s := FloatToStr(Zn);
if (Pos(',', s) > 0) and (Zn > 0) and
(Length(Copy(s, Pos(',', s) + 1, length(s))) > kol_zn) then
begin
s0 := Copy(s, 1, Pos(',', s) + kol_zn - 1);
s1 := Copy(s, 1, Pos(',', s) + kol_zn + 2);
s2 := Copy(s1, Pos(',', s1) + kol_zn, Length(s1));
n := StrToInt(s2) / 100;
nn := Round(n);
if nn >= 10 then
begin
snl := '0,';
for i := 1 to kol_zn - 1 do
snl := snl + '0';
snl := snl + '1';
n1 := StrToFloat(Copy(s, 1, Pos(',', s) + kol_zn)) + StrToFloat(snl);
s := FloatToStr(n1);
if Pos(',', s) > 0 then
s1 := Copy(s, 1, Pos(',', s) + kol_zn);
end
else
s1 := s0 + IntToStr(nn);
if s1[Length(s1)] = ',' then
s1 := s1 + '0';
Result := StrToFloat(s1);
end
else
Result := Zn;
end;
|