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

Michael Van Canneyt michael at freepascal.org
Fri Aug 6 16:52:34 CEST 2010

On Fri, 6 Aug 2010, Felipe Monteiro de Carvalho wrote:

> 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...

Strange, because tkCurrency exists ?

A currency is a Int64, which is the currency amount multiplied by 10000.

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

TDateTime IS a double.

The integer part is the number of days since 1/1/1900
The fractional part is the fraction of the day passed since 0:0

I believe this is documented. 
I also think this is not a Borland invention, but is introduced by Microsoft for variant datetime values.


More information about the fpc-pascal mailing list