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
CurrencyA decimal type with 4 decimal points used for financial values
DoubleA floating point type supporting about 15 digits of precision
ExtendedThe floating point type with the highest capacity and precision
 Download this web site as a Windows program.




 
Example code : Showing the precision and capacity of Single values
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;
Show full unit code
  Account1 = 0.123456791043282
  Account2 = 1.17999994577463E-38
  Account3 = 3.39999995214436E38
  Account4 = INF
 
Delphi Programming © Neil Moffatt . All rights reserved.  |  Home Page