FPC_CURRENCY_IS_INT64

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

FPC_CURRENCY_IS_INT64

LacaK
Hi,

what is the meaning of this compiler define?
I am expecting, that Currency datatype is internaly stored using Int64
datatype (*10000).
This compiler define is set for Win64, but not for Win32.
Does it means, that on Win32 there is Currency internaly represented
using another data type?

TIA

-Laco.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: FPC_CURRENCY_IS_INT64

Free Pascal - General mailing list
LacaK <[hidden email]> schrieb am Mo., 14. Okt. 2019, 11:08:
Hi,

what is the meaning of this compiler define?
I am expecting, that Currency datatype is internaly stored using Int64
datatype (*10000).
This compiler define is set for Win64, but not for Win32.
Does it means, that on Win32 there is Currency internaly represented
using another data type?

Correct. On all non-Win64 x86 systems the Currency type is a FPU based type. On non-x86 systems the Currency type is represented internally by a Int64 as well. 

Regards, 
Sven 

_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: FPC_CURRENCY_IS_INT64

LacaK

>> what is the meaning of this compiler define?
>> I am expecting, that Currency datatype is internaly stored using
>>Int64
>> datatype (*10000).
>> This compiler define is set for Win64, but not for Win32.
>> Does it means, that on Win32 there is Currency internaly represented
>> using another data type?
>>
>
> Correct. On all non-Win64 x86 systems the Currency type is a FPU
>based type.

x87 FPU based data types only when doing calculations inside FPU?
Am I right, that in memory layout is sam e as for Int64 on Win64 and also on Win32? When I try:

var
  c: currency:
  i: int64 absolute c;
begin
  // SizeOf(c) = SizeOf(i) = 8 on both Win32 and also Win64
  c:= <some value>;
  // then in "i" is c*10000
  writeln(i); // prints c*10000
end.

So in memory is stored always as int64 and when CPU/FPU is working with it then is converted to extended and loaded into FPU registers - FILD. And when stored back into memory FIST is used to convert value in FPU register to signed 64bit integer and stored into memory.
So it is safe to assume that in memory is Currency always stored as Int64 on Win32, Win64?

Thanks
-Laco.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: FPC_CURRENCY_IS_INT64

Florian Klämpfl
Am 14.10.19 um 19:40 schrieb LacaK:

> So it is safe to assume that in memory is Currency always stored as
> Int64 on Win32, Win64?

Yes. To get it's value, divide it by 10000
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal