System.TSingleRec
Delphi
TSingleRec = packed record
C++
struct DECLSPEC_DRECORD TSingleRec
{
private:
float aSingle;
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);
void __fastcall SetBytes(unsigned Index, const UInt8 Value);
void __fastcall SetWords(unsigned Index, const UInt16 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 UInt8 Bytes[unsigned Index] = {read=GetBytes, write=SetBytes};
__property UInt16 Words[unsigned Index] = {read=GetWords, write=SetWords};
};
Inhaltsverzeichnis
Eigenschaften
Typ | Sichtbarkeit | Quelle | Unit | Übergeordnet |
---|---|---|---|---|
record struct |
public | System.pas System.hpp |
System | System |
Beschreibung
Warnung: TSingleRec ist veraltet. Bitte verwenden Sie SysUtils.TSingleHelper.
TSingleRec kann Low-Level-Operationen mit Gleitkommawerten mit einfacher Genauigkeit durchführen.
Ab XE3 sind die Eigenschaften TSingleRec.Bytes und TSingleRec.Words Array-Eigenschaften. Die Operatoren System.High und System.Low können nicht für Array-Eigenschaften angewendet werden. Sie können stattdessen System.SizeOf wie im folgenden Beispiel verwenden.
Beispiel
In der XE2-Version dieses Beispiels wurde mit System.High und System.Low Byte für Byte durch TSingleRec wie folgt iteriert:
for I := High(F.Bytes) downto Low(F.Bytes) do
Im XE3-Beispiel wird System.SizeOf anstelle von High und Low verwendet:
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)));
// ...
Konsolenausgabe:
BF 00 00 00 -0.5