自已定个函数Rnd,以后要用调用一下就行了
interface
uses math;
type
function Rnd(SrcNum : Real;Position : integer=0) :real;
implementation
function Rnd(SrcNum: Real;
Position: integer=0): real;
var
temp1:real;
begin
temp1 := power(10,Position);
SrcNum := SrcNum * temp1;
if SrcNum >=0 then
begin
if SrcNum -Trunc(SrcNum) >= 0.5 then
Result := (Trunc(SrcNum) +1)/temp1
else
Result := Trunc(SrcNum)/temp1;
end
else
begin
if abs(SrcNum -Trunc(SrcNum)) >= 0.5 then
Result := (Trunc(SrcNum) -1)/temp1
else
Result := Trunc(SrcNum)/temp1;
end;
end;
var a,b,c:real;
begin
a:=5;
b:=3;
c:=rnd(a/b,2);
end;