Solved

Big endian and Little Endian?

Posted on 2006-11-16
5
2,404 Views
Last Modified: 2012-06-27
I am confused with the words Big endian and little endian.I know they are related to the processor type and they read the bits in different order.I wrote a program to find the machine is big endian or little endian and when i compiled the code on solaris using cc compiler,my output was big endian and when i compiled the same code on Turbo C on windows the output was little endian.

My exact question is

1) Wether the endianess depends upon the processor type or the platform type i,e OS type.

2) Which type is intel processor and motorola processor?





0
Comment
Question by:tatikor_143
  • 2
  • 2
5 Comments
 
LVL 45

Expert Comment

by:Kent Olsen
ID: 17959954

Endianness is dependent entirely on the processor.  No O/S would function as big endian when the hardware didn't support it.

Some processors actually support both/either.

Intel is definitely little endian.  If not for Intel this horrible approach to data storage might never have become popular.

Which Motorola chip.  As I recall, they've made both.



Kent
0
 

Author Comment

by:tatikor_143
ID: 17960134

If the endianess compleately depend on the processor type then why I am getting output as Big endian on solaris and little endian on windows using TC compiler.

Bcos I am compiling the code on the same machine but different platforms.

Please explain me,I am very eager to know the answer for this.
0
 
LVL 84

Expert Comment

by:ozo
ID: 17960391
what was your code and output?
0
 

Author Comment

by:tatikor_143
ID: 17960445
#include<stdio.h>

int main()
{

int a=1;

char *p;

p=( char *) &a;

if(*p==1)
{
printf("Little endian\n");
}

else
{

printf("Big endian");
}
return 0;
}

0
 
LVL 45

Accepted Solution

by:
Kent Olsen earned 500 total points
ID: 17960889

>> If the endianess compleately depend on the processor type then why I am getting output as Big endian on solaris and little endian on windows using TC compiler.

>> Bcos I am compiling the code on the same machine but different platforms.


If you're truly compiling the same code on the same machine, then the inherent expectations of the running operating systems are being observed.

Windows is little endian.  I'm unaware of any port that utilizes the big endian architecture.

Apparently, you're running on big endian Solaris system.


Kent
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question