Little Indian vs Big Indian
Big Endian = 0x31014950
Little Endian = 0x50490131
However using this method
inline unsigned int endian_swap(unsigned int& x)
{
return ( ( (x & 0x000000FF) << 24 ) |
( (x & 0x0000FF00) << 8 ) |
( (x & 0x00FF0000) >> 8 ) |
( (x & 0xFF000000) >> 24 ) );
}
result = 0x54110131
I spent a lot of time trying many similar methods and even a library like
unsigned long _byteswap_ulong(unsigned long value);
But still no luck .. everything returns the same result
EDIT
I'm working on a Little-Endian system with Microsoft Visual Studio 2008
example, as follows
int main()
{
unsigned int y = 0x31014950;
unsigned int r = endian_swap( y );
std::cout << r;
}
the example posted on Ideone.com is correct, but it does not work with me
EDIT
std::cout << std::hex << r;
Wails Pals.. Hex Not it not get the Right Number.. Visual Studio , .
Redunant ,
BTW, . Debugger , .