DelphiBasics
Single
Type
The smallest capacity and precision floating point type System unit
  type Single;
Description
The Single type is the fastest floating point type in Delphi. It also has the lowest storage requirements - 32 bits (1 for the sign 8 for the exponent, and 23 for the mantissa).
 
It supports approximately 7 digits of precision in a range from 1.18 x 10-38 to 3.4 x 1038.
Notes
The Double type is the general purpose floating point type, being higher in capacity and precision than the Single. It takes more storage and is slower however.

The Extended type has the highest capacity and precision, but biggest storage and worst performance.

A Single set to its highest value is treated as Infinity.
Related commands
Currency A decimal type with 4 decimal points used for financial values
Double A floating point type supporting about 15 digits of precision
Extended The floating point type with the highest capacity and precision
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

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




 
Example code : Showing the precision and capacity of Single values
// 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
  // The System unit does not need to be defined
  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
  account1, account2, account3, account4 : Single;
begin
  account1 := 0.1234567890123456789;   // 20 decimal places
  account2 := 1.18E-38;                // Lowest exponent value
  account3 := 3.4E38;                  // Highest exponent value
  account4 := 3.49E38;                 // Treated as infinite

  ShowMessage('Account1 = '+FloatToStr(account1));
  ShowMessage('Account2 = '+FloatToStr(account2));
  ShowMessage('Account3 = '+FloatToStr(account3));
  ShowMessage('Account4 = '+FloatToStr(account4));
end;
 
end.
Hide full unit code
   Account1 = 0.123456791043282
   Account2 = 1.17999994577463E-38
   Account3 = 3.39999995214436E38
   Account4 = INF
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Home Page