Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Big endian and Little Endian?

Posted on 2006-11-16
5
Medium Priority
?
2,414 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 46

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 85

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 46

Accepted Solution

by:
Kent Olsen earned 1000 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

Industry Leaders: 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

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
Suggested Courses

972 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