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

Felipe Monteiro de Carvalho felipemonteiro.carvalho at gmail.com
Sat Aug 7 23:39:08 CEST 2010


On Sat, Aug 7, 2010 at 10:44 PM, Zaher Dirkey <parmaja at gmail.com> wrote:
> A Currency is a Int64 not float, if you assign currency to float variable
> (double/extended) and return back to currency variable, you will not get the
> same value.

Interresting enough, the exact same value is returned. From my
research on this subject a floating point is something like:

Sign bit || exponent bits || decimal places

Num = sign * (2^(exponent - offset) + decimal places)

And the server only sends numbers like: 0,25; 0,5; 1; 2; 4; etc

All those numbers can be fully represented using the exponent, so the
double conversion maintains them exactly the same.

-- 
Felipe Monteiro de Carvalho



More information about the fpc-pascal mailing list