When executing the below code, it should calculate the distance to the horizon using the current height, but it is able to calculate only up to 63 meters high, then an 'Invalid Floating Point Operation' from 64 meters onwards.
Why is this error occurring?
unit Unit_ch4_2;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Label1: TLabel;
Label2: TLabel;
Edit2: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
r:real;
begin
r := SQRT(SQR(6350000 + StrToint(Edit1.Text)) - SQR(6350000));
Edit2.Text := FloatToStr(r / 1000);
end;
end.