|
|
四舍五入的BUG |
|
|
作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站 |
四舍五入的BUG |
|
关键词:四舍五入 |
Delphi的四舍五入函数Round有BUG,无法正常工作。
对于XXX.5的情况,整数部分是奇数,那么会Round Up,偶数会Round Down,例如:
x:= Round(17.5) = x = 18
x:= Round(12.5) = x = 12
请使用下面的函数代替Round:
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 ; | | | 
|
|
相关文章:相关软件: |
|