[fpc-pascal] Extended, Currency and TDateTime memory layout

Felipe Monteiro de Carvalho felipemonteiro.carvalho at gmail.com
Fri Aug 6 16:35:26 CEST 2010


Hello,

I am interfacing with a server written in Delphi via network and it
sends over data. The server sends some data types, and among the
hardest ones to read are Currency and TDateTime.

The server is undocumented and does some strange transformations of
the data using RTTI to pass properties.

I always though that Currency was a special kind of integer type, but
it seams that RTTI will return tkFloat for it under Delphi. Where is
the internal memory layout of Currency documented? Where is it
declared in the compiler? I couldn't find it...

Similarly, it seams that most often TDateTime=double. Any docs on the
memory layout of TDateTime?

Before sending the data over, the application seams to convert both
types to Extended ... any docs on the memory layout of that? I am
trying to convert the data that the server sends into a readable
number, but it doesn't seam to work, so maybe the memory layout of
this would help ...

A snap of what kind of stuff the server does:

var
  FloatProp: Extended;
  PropCnt, I: Integer;
  PropList: PPropList;
  ....
begin
...
    PropCnt := GetPropList(Result,PropList);
    for I := 0 to PropCnt - 1 do begin
      case PropList[I].PropType^^.Kind of
        ....
        tkFloat: begin
          Stream.Read(FloatProp, SizeOf(FloatProp));
          SetFloatProp(Result, PropList[i], FloatProp);
        end;

Plus, the Extended type is limited to x86 or does it also exist under
x86_64? As in having the same memory layout...

If it doesn't exist, does anyone know a function to read/write an
extended even without hardware support?

thanks,
-- 
Felipe Monteiro de Carvalho



More information about the fpc-pascal mailing list