DelphiBasics
IsInfinite
Function
Checks whether a floating point number is infinite Math unit
 function IsInfinite ( const FloatNumber : Double ) : Boolean;
Description
The IsInfinite function returns True if FloatNumber is infinite in value.
Related commands
Infinity Floating point value of infinite size
IsNaN Checks to see if a floating point number holds a real number
NaN Not a real number
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

 Buy Proxies at
 Buyproxies.io
 
 Download this web site as a Windows program.




 
Example code : Assign Infinity to a number and then test using IsInfinite
// Full Unit code.
// -----------------------------------------------------------
// You must store this code in a unit called Unit1 with a form
// called Form1 that has an OnCreate event called FormCreate.
 
unit Unit1;
 
interface
 
uses
  Math,   // Unit containing the IsInfinite command
  SysUtils,
  Forms, Dialogs;
 
type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  end;
 
var
  
Form1: TForm1;
 
implementation
{$R *.dfm} // Include form definitions
 
procedure TForm1.FormCreate(Sender: TObject);

var
  float : Double;

begin
  // Set the number to infinity
  float := Infinity;     // Equivalent to 1.0/0.0

  // Although infinite, we can still display it
  ShowMessage('float = '+FloatToStr(float));

  // And we can test to see if it is infinite
  if IsInfinite(float)
  then ShowMessage('float is infinite')
  else ShowMessage('float = '+FloatToStr(float));
end;
 
end.
Hide full unit code
   float = INF
   float is infinite
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Home Page