-1

I'm trying to make a calculator at delphi but I have a problem in the mod area, I haven't found how to solve it.

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;
Macex
  • 3
  • 3

1 Answers1

1

For the future, please specify an error you got.

But in this case it is easy to undestand the error. mod operator works with integer variables only, and you have double. You can write:

sonuc:= sayi1 - int(sayi1 / sayi2) * sayi2;  
Miamy
  • 2,162
  • 3
  • 15
  • 32