Re: [Dev-C++] Convert Little-Endian to Big-Endian (and vice versa)
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Cary H. <xen...@gm...> - 2004-11-11 14:54:27
|
two things you should be considered: 1. In my experience, endian conversion is primarly used in porting code to a different platform. consequently, 2. You shouldn't make assumptions about how many bits are in an given type, as different compliers on the same platform, and even the same compiler on different platforms will used different sizes. An good example of this is in the WinAPI, Win32 says an unsigned long is 32 bits, while Win64 says its 64. On Thu, 11 Nov 2004 04:54:13 +0000 (GMT), Joey Dala <jda...@ya...> wrote: > > Hello, > > Does anybody know a faster algorithm to swap the bytes > of an 'unsigned long' than this: > > // SWAP 32-BITS > #define SWAP_LONG( A ) ((A << 24) | ((A & 0xff00L) << 8 ) | ((A & > 0xff0000L) >> 8 ) | ((unsigned long)A >> 24)) > > Thank You. > Joey > > ________________________________ > Yahoo! Messenger - Communicate instantly..."Ping" your friends today! > Download Messenger Now > > |