System.TExtended80Rec

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

TExtended80Rec = packed record

C++

struct DECLSPEC_DRECORD TExtended80Rec
{
private:
#ifndef _WIN64
    Extended aExtended80;
#else /* _WIN64 */
    unsigned __int64 aExtended80Frac;
    UInt16 aExtended80Exp;
#endif /* _WIN64 */
    UInt8 __fastcall InternalGetBytes(unsigned Index);
    UInt16 __fastcall InternalGetWords(unsigned Index);
    void __fastcall InternalSetBytes(unsigned Index, const UInt8 Value);
    void __fastcall InternalSetWords(unsigned Index, const UInt16 Value);
    UInt8 __fastcall GetBytes(unsigned Index);
    UInt16 __fastcall GetWords(unsigned Index);
    unsigned __int64 __fastcall Get_Exp();
    unsigned __int64 __fastcall GetExp();
    unsigned __int64 __fastcall GetFrac();
    bool __fastcall GetSign();
    void __fastcall SetBytes(unsigned Index, const UInt8 Value);
    void __fastcall SetWords(unsigned Index, const UInt16 Value);
    void __fastcall Set_Exp(unsigned __int64 NewExp);
    void __fastcall SetExp(unsigned __int64 NewExp);
    void __fastcall SetFrac(unsigned __int64 NewFrac);
    void __fastcall SetSign(bool NewSign);
public:
    int __fastcall Exponent();
    Extended __fastcall Fraction();
    unsigned __int64 __fastcall Mantissa();
    __property bool Sign = {read=GetSign, write=SetSign};
    __property unsigned __int64 Exp = {read=GetExp, write=SetExp};
    __property unsigned __int64 _Exp = {read=Get_Exp, write=Set_Exp};
    __property unsigned __int64 Frac = {read=GetFrac, write=SetFrac};
    TFloatSpecial __fastcall SpecialType();
    void __fastcall BuildUp(const bool SignFlag, const unsigned __int64 Mantissa, const int Exponent);
    static TExtended80Rec __fastcall _op_Explicit(Extended a);
    __property UInt8 Bytes[unsigned Index] = {read=GetBytes, write=SetBytes};
    __property UInt16 Words[unsigned Index] = {read=GetWords, write=SetWords};
};

Properties

Type Visibility Source Unit Parent
record
struct
public
System.pas
System.hpp
System System

Description

Provides support for manipulating extended precision floating-point values.

A TExtended80Rec can be used to perform low-level operations on an extended precision floating-point value. For example, the sign, the exponent, and the mantissa can be changed separately.

In Delphi on Win32, the Extended data type is 10 bytes. On Win64, however, the Extended data type is only 8 bytes. Using TExtended80Rec on Win64 enables you to perform memory-related operations with 10-bit floating-point variables, but not extended-precision arithmetic operations.

Note:

Example

 
var
  F: TExtended80Rec;
  E: Extended;
  I: Integer;
const
  TAB = Chr(9);
begin
  F := TExtended80Rec(-66.3);

  Writeln('Sign: ' + TAB + TAB + IntToStr(Integer(F.Sign)));
  Writeln('Exponent: ' + TAB + IntToStr(Integer(F.Exp)));
  Writeln('Mantissa: ' + TAB + IntToHex(UInt64(F.Mantissa), 16));

  // Subtract 1 from exponent
  // This is equivalent with division by 2
  F.Exp := F.Exp - 1;

  E := Extended(F);
  Writeln('Size of Extended: ' + TAB + IntToStr(SizeOf(E))); // displays 10 on Win32 and 8 on Win64
  Writeln(FloatToStr(E)); // displays -33.15 (-66.3 / 2)

  // ...

Console output if the size of extended is 10 bytes:

Sign:          1
Exponent:       16389
Mantissa:       849999999999999A
Size of Extended:       10
-33.15

Console output if the size of extended is 8 bytes:

Sign:          1
Exponent:       16389
Mantissa:       8499999999999800
Size of Extended:       8
-33.15

The floating-point constant "-66.3" is evaluated as 64-bits precision if the size of the extended type is 80-bit. But if the size of extended is 64-bit, "-66.3" is evaluated as only 53-bit precision even if TExtended80Rec can handle 64-bit. This is the reason why Mantissa (and Fraction) have a difference.


See Also