473,320 Members | 2,193 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Little endian big endian

13
Hi to all,

i want a program to find little endian or big endian processor?

can u help me plz.....
Feb 16 '07 #1
9 3133
sicarie
4,677 Expert Mod 4TB
Hi to all,

i want a program to find little endian or big endian processor?

can u help me plz.....
Sure, what do you have so far?
Feb 16 '07 #2
Banfa
9,065 Expert Mod 8TB
i want a program to find little endian or big endian processor?
Why?

I have yet to think of a good reason for needing a program like this.
Feb 16 '07 #3
sicarie
4,677 Expert Mod 4TB
Why?

I have yet to think of a good reason for needing a program like this.
There's probably not, but I remember writing a program to tell the difference when I was a sophomore :) (I was on one of those "I need to code something every day to keep up with it" stints. I wish I'd stayed on it...).
Feb 16 '07 #4
RRick
463 Expert 256MB
This problem shows up in networks when dealing with different processor architectures. If you're passing around binary info, you have to be very careful how you transmit it over the net. I believe the socket routines htons, etc. deal with this. If you have a homebrew/propriatary protocol you'll have to do this yourself.

Refer to the following link. The company that was interested in this question was a high powered networking company. http://www.thescripts.com/forum/thread603165.html
Feb 17 '07 #5
gmu
1
Hi,
Incase you are still looking for the answer for little big endian conversion checkout www.compinterview.com, there is a solution for this and many such interview question problems :)

Gmu
Feb 18 '07 #6
DeMan
1,806 1GB
Incedently, I have come across situations where knowing endianness is significant -> some conventions require data to be stored a particular way, irresepective of endianness (eg PVK) -> if someone else (not necessarly using the same endianness) needs to be able to access this information, you need to be sure that the format is correct to the specification.
Part of me says: if you write this for a specific machine, you know the endianness and can write the program specifically for the purpose, but I can almost see where someone may attempt to write code that will run on either (and thus, in the case of PVK would need to convert to little endian on big endian machines, and do nothing on little endian machines).....
Feb 18 '07 #7
Hi ,


I want to know how to find the little-endian and big-endian of the processor by using C programming lanaguage. If any one experts of this area or known plz tell me how to do that.

and also programming explanation means goods, example programs.

Because it is asked in one interview question for me, please help me.

i am awaiting your reply.
Mar 12 '07 #8
DeMan
1,806 1GB
Did you know UNICODE files start with the combination 0xff 0xfe?
Mar 12 '07 #9
Banfa
9,065 Expert Mod 8TB
Incedently, I have come across situations where knowing endianness is significant -> some conventions require data to be stored a particular way, irresepective of endianness (eg PVK) -> if someone else (not necessarly using the same endianness) needs to be able to access this information, you need to be sure that the format is correct to the specification.
Part of me says: if you write this for a specific machine, you know the endianness and can write the program specifically for the purpose, but I can almost see where someone may attempt to write code that will run on either (and thus, in the case of PVK would need to convert to little endian on big endian machines, and do nothing on little endian machines).....
This is true, I have worked on satellite receivers that had a number of different processors with different endians but the DVB/MPEG2 specification specifies the byte order for the data received.

However you do not need to work out which endian the processor has, you just have to write you code so that the endian of the processor is irrelivent to the operation of the code. This isn't that hard to do.

For instance you have a buffer with 2 bytes in it which form a short value big with the data in the buffer stored endian.

Expand|Select|Wrap|Line Numbers
  1. unsigned char DataBuffer[2];
  2. unsigned short value;
  3.  
  4. // code to fill in DataBuffer from some source
  5.  
  6. value = (((unsigned short)DataBuffer[0]<<8) | (unsigned short)DataBuffer[1]);
  7.  
This will work regardless of the endian of the processor it is run on.
Mar 12 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: hicham | last post by:
Hi, I am looking for help, i would like to know how can i use the endian.h and config.h to convert compiled files under solaris from BIG-ENDIAN to compiled files LITTLE-ENDIAN. I am working...
3
by: gary | last post by:
Hi, 1. About all C/C++ compilers, Does stack increase from high address to low address and heap grow increase from low to high? What on earth decides their increase direction, CPU architecture, OS...
8
by: Perception | last post by:
Hello all, If I have a C-like data structure such that struct Data { int a; //16-bit value char; //3 ASCII characters int b; //32-bit value int c; //24-bit value }
2
by: bhatia | last post by:
Hello all, If I have a C-like data structure such that struct Data { int a; //16-bit value char; //3 ASCII characters int b; //32-bit value int c; //24-bit value }
5
by: manishster | last post by:
I keep getting the following in my output file , regardless of whether I convert endian-ness or not . How do i get "01 02 03 04" .... Mahamannu output : 04 03 02 01 b0 00 00
3
RRick
by: RRick | last post by:
This was a question that showed up in a job interview once. (And to answer your next question: No, I didn't :)) Write a subroutine that returns a bool on whether a system supports big endian...
6
by: Javier | last post by:
Hello people, I'm recoding a library that made a few months ago, and now that I'm reading what I wrote I have some questions. My program reads black and white images from a bitmap (BMP 24bpp...
23
by: guthena | last post by:
Write a small C program to determine whether a machine's type is little-endian or big-endian.
2
by: Ramesh | last post by:
Hi I have a structure as below on big endian based system typedef struct { unsigned long LedA:5; unsigned long LedB:4; unsigned long LedC:8;
23
by: Niranjan | last post by:
I have this program : void main() { int i=1; if((*(char*)&i)==1) printf("The machine is little endian."); else printf("The machine is big endian."); }
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.