title: Invalid Floating Point Operation
body: <p>I keep getting this error "Invalid Floating Point Operation".</p>
  
  <p>I'm on Delphi 7.</p>
  
  <pre><code>uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  TlHelp32, Dialogs, StdCtrls, ExtCtrls, Buttons, ComCtrls;
  
  var //global
  PHandle, cancel, bytes, scantype: integer;
  </code></pre>
  
  <p>...</p>
  
  <pre><code>procedure Tmain.scanbtnClick(Sender: TObject);
      var max, address: Integer;
      floatinput, floatinput1, floatinput2, datafloat: Real;
      x: cardinal;
      itm: TListItem;
  begin
  
    floatinput := StrToFloat(Trim(valueinput.Text));
    floatinput1 := StrToFloat(Trim(valueinput1.Text));
    floatinput2 := StrToFloat(Trim(valueinput2.Text));
  
    if floatinput2 &lt; floatinput1 then
    begin
      floatinput1 := floatinput1 + floatinput2;
      floatinput2 := floatinput1 - floatinput2;
      floatinput1 := floatinput1 - floatinput2;
    end;
  
    result.Show;
  
    x := 0;
    address := 0;
  
    result.resultlist.Clear;
  
    repeat
      Application.ProcessMessages;
      statusbar1.Panels.Items[1].Text := 'Searching... ' + IntToStr(address * 100 div max) + '% (' + IntToStr(address div bytes) + ' out of ' + IntToStr(max div bytes) + ').';
  
      if ReadprocessMemory(PHandle, Ptr(address), @datafloat, bytes, x) then
        begin
          if (x &gt; 0) then
          begin
            if scantype = 0 then
            begin
              if datafloat = floatinput then             //error here
              begin
                itm := result.resultlist.Items.Add;
                itm.Caption := '0x' + IntToHex(address,8);
                itm.SubItems.Add(FormatFloat('0.0#########', datafloat));
              end;
            end;
            if scantype = 1 then
            begin
              if datafloat &gt; floatinput              //also here
              then begin
                itm := result.resultlist.Items.Add;
                itm.Caption := '0x' + IntToHex(address,8);
                itm.SubItems.Add(FormatFloat('0.0#########', datafloat));
              end;
            end;
            if scantype = 2 then
            begin
              if datafloat &lt; floatinput     //here too
              then begin
                itm := result.resultlist.Items.Add;
                itm.Caption := '0x' + IntToHex(address,8);
                itm.SubItems.Add(FormatFloat('0.0#########', datafloat));
              end;
            end;
            if scantype = 2 then
            begin
              if (dataint &lt;= intinput2) and (dataint &gt;= intinput1)    //even here
              then begin
                itm := result.resultlist.Items.Add;
                itm.Caption := '0x' + IntToHex(address,8);
                itm.SubItems.Add(FormatFloat('0.0#########', datafloat));
              end;
            end;
  
          end;
        end;
  
      if x &lt;&gt; 0
      then address := address + x
      else address := address + bytes;
  
    until (address &gt;= Max) or (cancel = 1);
  
  end;
  </code></pre>
  
  <p>I even checked on the cpu window, and it happens because its trying to load a floating point value from a pointer that is pointing at a null value.</p>
  
  <p>It's not the ReadMemory, because this little piece of code is on a while loop and it returns several valid values before running into this error.</p>
  
  <p>What should I do?</p>
  
  <p>Thanks in advance.</p>