Sign in Join

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

Mailing lists / fpc-pascal / 2009-08

Switch Endian

3 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

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

Unknown author

Hi,

there's a pascal function to switch endian (for a 32 bit integer)? Note that it should work on 64 bit systems...

Mattias Gärtner
to Unknown author

Zitat von

Show quoted text 5 lines
Hi, there's a pascal function to switch endian (for a 32 bit integer)? Note that it should work on 64 bit systems...

There are many in the system unit:
SwapEndian
leton
beton

Mattias

Jonas Maebe
to Unknown author: there's a pascal function to switch endian (for a 32 bit integer)? Note that it should…
there's a pascal function to switch endian (for a 32 bit integer)? Note that it should work on 64 bit systems...

Use SwapEndian(longint(value)). The extra longint type cast is to ensure that you call the 32 bit version, regardless of the result type of the expression. We still have to add extra swapendianword/ swapendiandword/... etc functions which unambiguously specify the size they operate on.

Jonas