Solved

Big endian and Little Endian?

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
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…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
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.

770 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