SIGFPE错误,为什么?

时间:2011-04-10 03:06:25

标签: delphi

我有以下代码:

procedure TForm1.FormCreate(Sender: TObject);
var
  cpic: tcomponent;
  whichcol: integer; // have tried extended types
  whichrow: integer; // have tried extended types
begin
  for cpic in form1 do
  begin
    if (cpic.ClassType = timage) and (cpic.Tag = 10) then
    begin
      whichcol := timage(cpic).left - left div gap;
      whichrow := timage(cpic).Top - top div gap;
    end;
  end;
end;

这会导致以下错误:

  

错误

     

Project project1.exe引发了异常类'External:SIGFPE'。

使用:如概述的错误:

whichcol := (timage(cpic).left - left) div gap;

这个等式不应该只返回一个数值吗?

1 个答案:

答案 0 :(得分:4)

SIGFPE =浮点错误。

听起来像是一个零除。您确定gap不为零吗?