Little Endian vs Big Endian
Big Endian = 0x31014950
Little Endian = 0x50490131
However Using this Method
inline unsigned int endian
Bit operators are not useful because they operates as if the bits are arranged in order from least significant bit to most significant bit regardless of the true internal byte order.
void isBigEndian()
{
void *number;
number = (int *) new int(0x01000010);
// 0x01000010
// 01 00 00 10 Hexadecimal
// 0 1 0 0 0 0 1 0
// 0000 0001 0000 0000 0000 0000 0001 0000 Bit
// 1 0 0 16 Decimal
char *byte;
byte = (char *)number;
cout << static_cast(*byte);//prints 16: Little Endian
}
You change the number above and make it return 1 when it is BigEndian.