mod 和 delphi 案例无法协同工作

mod and case not working together for delphi

我正在尝试在delphi做一个计算器,但是我在mod方面遇到了问题,我还没有找到解决方法。

procedure TfrmHesapMakinesi.Button1Click(Sender: TObject);
var
sayi1:double;
sayi2:double;
sonuc:double;
islem:byte;
begin
       islem:=(Sender as TButton).Tag;
       sayi1:=strtofloatdef(edtSayi1.Text,0);
       sayi2:=strtofloatdef(edtSayi2.Text,0);
   case islem of
    1:sonuc:=sayi1+sayi2;
    2:sonuc:=sayi1-sayi2;
    3:sonuc:=sayi1*sayi2;
    4:sonuc:=sayi1/sayi2;
    5:sonuc:=sayi1 mod sayi2; //ERROR
  else
    ShowMessage('İşlem seçiniz');
  end;
       lblsonuc.Caption:=floattostr(sonuc);


end;

为了以后,请指出您遇到的错误。

但在这种情况下很容易理解错误。 mod 运算符仅适用于整数变量,而您有 double。你可以这样写:

sonuc:= sayi1 - int(sayi1 / sayi2) * sayi2;