Write a MIPS program to check if computer is a big-endian or little-endian system
In C, C++
int n = 1;
// little endian if true
if(*(char *)&n == 1) {...}
*In Python:
from sys import byteorder
print(byteorder)
# will print 'little' if little endian
If you are using .NET: Check the value of BitConverter.IsLittleEndian.
*In Linux,
static union { char c[4]; unsigned long mylong; } endian_test = { { 'l', '?', '?', 'b' } };
#define ENDIANNESS ((char)endian_test.mylong)
if (ENDIANNESS == 'l') /* little endian */
if (ENDIANNESS == 'b') /* big endian */
Get Answers For Free
Most questions answered within 1 hours.