Difference between revisions of "IEEE 754 formats"

From Free Pascal wiki
Jump to navigationJump to search
Line 3: Line 3:
 
Single is IEEE 754 single-precision binary floating-point format.
 
Single is IEEE 754 single-precision binary floating-point format.
  
Value range: 1.5E-45 .. 3.4E38
+
Value range: 1.5E-45 .. 3.4E38 <br>
Accuracy: 6-9 significant decimal digits precision
+
Accuracy: 6-9 significant decimal digits precision <br>
Memory requirement: 4 bytes or 32 bits
+
Memory requirement: 4 bytes or [[32 bit]]s <br>
 
Property: The single- data-type data field can hold floating-point values ​​and signed and unsigned integer values.
 
Property: The single- data-type data field can hold floating-point values ​​and signed and unsigned integer values.
 
Assigning other values ​​will result in error messages from the compiler when the program is compiled, and the compile will be aborted. That is, the executable program is not created.
 
Assigning other values ​​will result in error messages from the compiler when the program is compiled, and the compile will be aborted. That is, the executable program is not created.

Revision as of 12:00, 28 March 2018

English (en)

Single is IEEE 754 single-precision binary floating-point format.

Value range: 1.5E-45 .. 3.4E38
Accuracy: 6-9 significant decimal digits precision
Memory requirement: 4 bytes or 32 bits
Property: The single- data-type data field can hold floating-point values ​​and signed and unsigned integer values. Assigning other values ​​will result in error messages from the compiler when the program is compiled, and the compile will be aborted. That is, the executable program is not created.

Definition of a data field of data type Single:

  var 
    s : Single ;

Examples of assigning valid values:

    s : = - 123.45678 ;
    s : = 0 ;
    s : = 123.45678 ;

Examples of assigning invalid values:

    s : = '-123.45678' ;
    s : = '0' ;
    s : = '123.45678' ;

The difference between the two examples is that the upper example is the assignment of Integer and FloatingCommand literals, while the assignment of the lower example is literals of the String type.

Binary floating-point format

Any value stored as a single requires 32 bits, formatted as shown in the table below:

Bits Usage
31 Sign (0 = positive, 1 = negative)
30 to 23 Exponent, biased by 127
22 to 0 Fraction f of the number 1.f