Interview Questions and Answers :: Aricent
Home > Experience Archives > Aricent > Interview Question Set 1 > Discussion
5. What is little endian & big endian. How you will identify little endian machine.
Answer:
Little and big endian are two ways of storing multibyte data-types ( int, float, etc). In little endian machines, last byte of binary representation of the multibyte data-type is stored first. On the other hand, in big endian machines, first byte of binary representation of the multibyte data-type is stored first.
#include <stdio.h> int main() { unsigned int i = 1; if ( char *)&i) printf ( "Little endian" ); else printf ( "Big endian" ); return 0; }
|
Amit
9 Jul, 2018 10:19 AM
Little and big endian are two ways of storing multibyte data-types ( int, float, etc). In little endian machines, last byte of binary representation of the multibyte data-type is stored first. On the other hand, in big endian machines, first byte of binary representation of the multibyte data-type is stored first.
#include <stdio.h> int main() { unsigned int i = 1; if ( char *)&i) printf ( "Little endian" ); else printf ( "Big endian" ); return 0; }
|
Report Error
Report Error
Please Login First Click Here