System.TDoubleHelper
Delphi
type TDoubleHelper = record helper for Double;
C++
typedef void *TDoubleHelper;
Contents |
Properties
| Type | Visibility | Source | Unit | Parent |
|---|---|---|---|---|
helper typedef |
public | System.pas System.hpp |
System | System |
Description
Provides support for performing low-level operations on single precision floating-point values.
Double numbers are represented on 64 bits: 1 bit for Sign, 11 for Exponent, and 52 for Fraction. The bias is 1023.
For assigning the Sign, the Mantissa, and the Exponent, use the BuildUp method.
The TDoubleHelper methods Exponent, Fraction, and Mantissa provide access to the raw parts of the number.
Example
var aNumber: Double; begin aNumber := 28; Writeln(Format('Number: %f', [aNumber])) ; Writeln(Format('Exponent: %d', [aNumber.Exp])); Writeln(Format('Fraction: %x', [aNumber.Frac])); Writeln(Format('Mantissa: %x', [aNumber.Mantissa])); end;
Console output:
Number: 28.00 Exponent: 1027 Fraction: C000000000000 Mantissa: 1C000000000000
The number 28 is represented in binary as 11100. After the normalization, it is 1.1100 * 2^4.
The Sign is 0.
The Exponent is 4, represented in single precision as 1023 (the bias) + 4 = 1027. 1027 is 10000000011 in binary.
The Fraction is formed from the bits after comma: 1100. The Fraction is represented in 52 bits, so we fill the 1100 sequence up to 52 digits with zeros: 11000000000000000000000000000000000000000000000000000, in hexadecimal, C000000000000.
The Mantissa is formed from the Fraction with 1 bit before: 11100000000000000000000000000000000000000000000000000, in hexadecimal 1C000000000000.
Note: TDoubleHelper offers the support TDoubleRec used to. TDoubleRec is obsolete; use TDoubleHelper instead.