System.TSingleRec

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

TSingleRec = packed record

C++

struct DECLSPEC_DRECORD TSingleRec
{
private:
    float aSingle;
    Byte __fastcall InternalGetBytes(unsigned Index);
    Word __fastcall InternalGetWords(unsigned Index);
    void __fastcall InternalSetBytes(unsigned Index, const Byte Value);
    void __fastcall InternalSetWords(unsigned Index, const Word Value);
    Byte __fastcall GetBytes(unsigned Index);
    Word __fastcall GetWords(unsigned Index);
    void __fastcall SetBytes(unsigned Index, const Byte Value);
    void __fastcall SetWords(unsigned Index, const Word Value);
    unsigned __int64 __fastcall GetExp();
    unsigned __int64 __fastcall GetFrac();
    bool __fastcall GetSign();
    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 Frac = {read=GetFrac, write=SetFrac};
    TFloatSpecial __fastcall SpecialType();
    void __fastcall BuildUp(const bool SignFlag, const unsigned __int64 Mantissa, const int Exponent);
    static TSingleRec __fastcall _op_Explicit(Extended a);
    __property Byte Bytes[unsigned Index] = {read=GetBytes, write=SetBytes};
    __property Word Words[unsigned Index] = {read=GetWords, write=SetWords};
};

Properties

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

Description

Warning: TSingleRec is deprecated. Please use SysUtils.TSingleHelper.

TSingleRec can perform low-level operations on a single precision floating-point value.


Beginning from XE3, the TSingleRec.Bytes and TSingleRec.Words properties are array properties. System.High and System.Low operators do not apply for array properties. You can use System.SizeOf instead, as shown in the following example.

Example

In the XE2 version of this example, System.High and System.Low were used for iterating byte by byte through the TSingleRec, like this:

  for I := High(F.Bytes) downto Low(F.Bytes) do

In the XE3 example, System.SizeOf is used instead of High and Low:

var
  F: TSingleRec;
  I: Integer;

begin
  F := TSingleRec(-0.5);

  // display the hexadecimal representation of the single precision floating-point value
  // leftmost bytes are the most significant
  for I := sizeof(F) - 1 downto 0 do
    Write(IntToHex(F.Bytes[I], 2) + ' ');
  Writeln;

  // display the value contained in the TSingleRec record
  Writeln(FloatToStr(Single(F)));

  // ...

Console output:

BF 00 00 00
-0.5

See Also