Write a subroutine that returns a bool on whether a system supports big endian numbers (true) or little endian (false). I tried something like the following, but never did find out if it was correct.
There are two assumptions here: First, big endian direction from small to large is ordered like a string. Second, endian is byte based. On a PC, I get a true value. Does anyone know what goes on with the PC architecture?
Expand|Select|Wrap|Line Numbers
- bool isBigEndian( void)
- {
- union Endian
- {
- int iValue;
- char bValue;
- };
- Endian endian;
- endian.iValue = 1;
- return endian.bValue;
- }