0

In previous versions of Delphi (we use Delphi 2009), the TFloatRec record (used in floatToDecimal) was defined as

 TFloatRec = packed record
    Exponent: Smallint;
    Negative: Boolean;
    Digits: array[0..20] of AnsiChar;
 end;

However in Delphi XE5 (and I think this may have changed in XE3), it is defined as ..

 TFloatRec = packed record
    Exponent: Smallint;
    Negative: Boolean;
    Digits: array[0..20] of Byte;
  end;

We use this record to convert an extended field to a RawByteString, can anyone suggest what I can do to convert the results of the call to FloatToDecimal into a RawByteString.

Context

This method is called whilst reading a buffer from a network communication, so it needs to be as quick as possible, without converting codepages, etc.

Johan
  • 74,508
  • 24
  • 191
  • 319
mmmm
  • 2,431
  • 2
  • 35
  • 56

1 Answers1

4

You can just re-declare the D2009 record for your own use:

type
  TMyFloatRec = packed record
    Exponent: Smallint;
    Negative: Boolean;
    Digits: array[0..20] of AnsiChar;
  end;

Switch your existing code to use this record and all will be well.

Although it would also presumably be easy enough to do whatever it is you do with the new version of TFloatRec. After all a Byte and an AnsiChar are the same size and you can readily cast between one and the other.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • Staring at the code for too long. I have defined the structure as it was in Delphi2009 and cast it to the one in DelphiXE5. – mmmm Oct 01 '13 at 09:48