首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

Is it delphi`s bug?解决方法

2012-04-01 
Is it delphi`s bug?????procedureTForm1.Button1Click(Sender:TObject)vartempInt:integerbegintempInt

Is it delphi`s bug?????
procedure   TForm1.Button1Click(Sender:   TObject);
var
        tempInt:   integer;
begin
        tempInt   :=   Floor((7.2   -   7)   *   10);
        showmessage(IntToStr(tempInt));
end;

//run   the   procedure   behind   and   tell   me   why?
//why   the   result   is   1   not   2????
//Is   it   delphi`s   bug?

[解决办法]
不是BUG,是你对浮点数字理解不够。


Floor(1.99999999999)你觉得应该是多少?

(7.2-7)*10 = 1.999999999999999999999999999999999999...
(7.2-7)*10 != 2

热点排行