Solved

Big endian and Little Endian?

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Where is my core dump file in Ubuntu? 12 440
Best UNIX-compatible free C compiler for Windows or Mac 6 237
Problem to save 10 147
Super Scope, DHCP 5 50
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…
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…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.

929 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

14 Experts available now in Live!

Get 1:1 Help Now