[fpc-pascal] Endian & Hex numbers

Michael Van Canneyt michael at freepascal.org
Mon Apr 13 15:15:17 CEST 2015



On Mon, 13 Apr 2015, Torsten Bonde Christiansen wrote:

> Hi list.
> 
> Please forgive me if this is too dumb a question, but:
> 
> When using a const written in hex, is the order significant?
> Ie. will eg. $1F01 result in the same value (7937) on both big-endian and little endian machines?

Yes. 
It will be stored differently in memory, but the representation of the value is the same, regardless of the storage.

> 
> 
> Likewise, if I use an absolute reference to a variable is the endianness also significant?
> ex.:
> 
> const
>   A: SmallInt = $1F01;
> 
> var
>   B: array[0..1] of byte absolute A;
> 
> 
> Will B[0] be the same on both types of endian machines?

No, because here you actually access the memory, and the memory layout will differ.

Michael.


More information about the fpc-pascal mailing list