Solved

Big endian and Little Endian?

Posted on 2006-11-16
5
2,399 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:Kdo
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:
Kdo 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now