Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2015-04

Endian & Hex numbers

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Torsten Bonde Christiansen

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?

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?

Regards,
Torsten.

Reply by email

Michael Van Canneyt
to Torsten Bonde Christiansen
Torsten Bonde Christiansen wrote 6 lines
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.

Show quoted text 13 lines
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.

Reply by email