function DoRound(Value: Extended): Int64;
procedure Set8087CW(NewCW: Word);
asm MOV Default8087CW,
AX FNCLEX FLDCW Default8087CW end;
const RoundUpCW = $1B32;var OldCW : Word;
begin OldCW := Default8087CW;
try
Set8087CW(RoundUpCW);
Result := Round(Value);
finally
Set8087CW(OldCW);
end;
end;
或
function RoundFloat(f:double;i:integer):double;
var
s:string;
ef:extended;
begin
s:='#.'+StringOfChar('0',i);
ef:=StrToFloat(FloatToStr(f));//防止浮点运算的误差
result:=StrToFloat(FormatFloat(s,ef));
end;