Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Can somebody share difference between big and little endian

Off-Topic discussions about science, technology, and non Debian specific topics.
Post Reply
Message
Author
shirish
Posts: 845
Joined: 2010-12-08 12:59

Can somebody share difference between big and little endian

#1 Post by shirish »

Hi all,
I had read about big and little endian and did read http://www.cs.umd.edu/class/sum2003/cms ... ndian.html but didn't understand anything.

The gist I got though is that information which is in one format cannot be transferred to other without some sort of conversion.

Unfortunately the link/page didn't do a good page explaining it to those (like me) whose understanding of memory and array is very weak. Can somebody take a stab at it.

Also does anybody know of any programs in Debian which do this sort of conversion ?

Another thing, where does amd64 come into the picture ? is 386 and amd64 little endian or big endian ?

Looking forward to know more.
Intel Dual-Core CPU E5400 (soc 775) @ 2.70GHz, onboard Intel G33, Asus MB P5KPL-AM IN (Intel G31), D-Link 2750u modem+router, 64-bit Debian Testing, Mate 1.26

BowCatShot
Posts: 959
Joined: 2006-07-15 12:08

Re: Can somebody share difference between big and little end

#2 Post by BowCatShot »

Here's what wikipedia says about it:

Big-endian systems store the most significant byte of a word in the smallest address and the least significant byte is stored in the largest address.
Little-endian systems, in contrast, store the least significant byte in the smallest address.

So if you have a 2 byte integer containing the value 32766, or 7ffe in hex, a big endian system would store it as fe7f while little endian would store it as 7ffe. Where this matters is when a big endian system is transmitting data to a little endian system. The protocol would have to take that into consideration.

User avatar
hakerdefo
Posts: 258
Joined: 2014-05-05 05:31

Re: Can somebody share difference between big and little end

#3 Post by hakerdefo »

The following article describes the difference in the easiest way,
Big and Little Endian
Cheers!!!

reinob
Posts: 1198
Joined: 2014-06-30 11:42
Has thanked: 99 times
Been thanked: 47 times

Re: Can somebody share difference between big and little end

#4 Post by reinob »

hakerdefo wrote:The following article describes the difference in the easiest way,
Big and Little Endian
Cheers!!!
You just posted the same link the OP posted, where he explicitly indicated that he did not understand it.
Your point is?

User avatar
hakerdefo
Posts: 258
Joined: 2014-05-05 05:31

Re: Can somebody share difference between big and little end

#5 Post by hakerdefo »

reinob wrote:You just posted the same link the OP posted, where he explicitly indicated that he did not understand it.
Your point is?
I didn't check the link Shirish posted and searched the internet for a good article on big & little Endian and after going through many articles on the subject I posted the link to what I thought to be the best and easiest article.
Weird, ain't it?!?
Cheers!!!

reinob
Posts: 1198
Joined: 2014-06-30 11:42
Has thanked: 99 times
Been thanked: 47 times

Re: Can somebody share difference between big and little end

#6 Post by reinob »

hakerdefo wrote:
reinob wrote:You just posted the same link the OP posted, where he explicitly indicated that he did not understand it.
Your point is?
I didn't check the link Shirish posted and searched the internet for a good article on big & little Endian and after going through many articles on the subject I posted the link to what I thought to be the best and easiest article.
Weird, ain't it?!?
Cheers!!!
Indeed :)

@shirish,
In case you still have not found an answer to your questions..
Unfortunately the link/page didn't do a good page explaining it to those (like me) whose understanding of memory and array is very weak. Can somebody take a stab at it.
Let's say you have a memory, which is an array (sequence) of 8-bit bytes, each one having an address from 0 (zero) to 1024 (for example).

You want to store a 16-bit number, e.g. 4660 (in decimal). That number is 0x1234 in hexadecimal (the "0x" prefix serves to clarify that).

Now you could store it this way:
FIRST MEMORY BYTE: 0x12
SECOND MEMORY BYTE: 0x34

or

FIRST MEMORY BYTE: 0x34
SECOND MEMORY BYTE: 0x12

If you do it the first way then you're "big endian" (~ straightforward, intuitive). If you do it the second way you're "little endian" (~ swapped, weird, counter-intuitive: used by all x86 processors :).

Clear?

If so, you can now imagine what happens when you store a 32-bit number (i.e. using 4 8-bit memory bytes) or even a 64-bit number, but first you need to confirm that you've understood the case for 16-bit.
Also does anybody know of any programs in Debian which do this sort of conversion ?
You should never need to do this, unless you happen to have a binary file where you want to swap bytes. Please ask again if you really need this (you could program it yourself as an excercise -- then you'll understand clearly the endianness topic).
Another thing, where does amd64 come into the picture ? is 386 and amd64 little endian or big endian ?
little.

User avatar
hakerdefo
Posts: 258
Joined: 2014-05-05 05:31

Re: Can somebody share difference between big and little end

#7 Post by hakerdefo »

@reinob Great job man! Very nicely explained! You must be a teacher. If you are not then you are in the wrong field! ;)
Cheers!!!

User avatar
llivv
Posts: 5340
Joined: 2007-02-14 18:10
Location: cold storage

Re: Can somebody share difference between big and little end

#8 Post by llivv »

https://en.wikipedia.org/wiki/Endianness

Dorothy, are you still in Kansas? :wink:
In memory of Ian Ashley Murdock (1973 - 2015) founder of the Debian project.

User avatar
hakerdefo
Posts: 258
Joined: 2014-05-05 05:31

Re: Can somebody share difference between big and little end

#9 Post by hakerdefo »

llivv wrote:Dorothy, are you still in Kansas? :wink:
llivv, I've a feeling we're not in Kansas anymore :wink:
Another good article on the subject,
http://www.ietf.org/rfc/ien/ien137.txt
Cheers!!!

User avatar
llivv
Posts: 5340
Joined: 2007-02-14 18:10
Location: cold storage

Re: Can somebody share difference between big and little end

#10 Post by llivv »

hakerdefo wrote:llivv, I've a feeling we're not in Kansas anymore :wink:
For me it's
"More than a Feeling" :wink:
search youtube if the qoute doesn't spark any memories.

thanks for the link http://www.ietf.org/rfc/ien/ien137.txt
paragraph 7 reads
"Computer memory may be viewed as a linear sequence of bits, divided into
bytes, words, pages and so on. Each unit is a subunit of the next
level. This is, obviously, a hierarchical organization."

currently, The ultimate assembly line, in our ever increasing world of assembly lines.
In memory of Ian Ashley Murdock (1973 - 2015) founder of the Debian project.

User avatar
hakerdefo
Posts: 258
Joined: 2014-05-05 05:31

Re: Can somebody share difference between big and little end

#11 Post by hakerdefo »

llivv wrote:For me it's
"More than a Feeling" :wink:
search youtube if the qoute doesn't spark any memories.
Listened to them a lot in the old days when my parents used to think I was a wayword son.
Haven't listened to their music in recent times but wayword son I still am :)
Cheers!!!

dezingg
Posts: 19
Joined: 2014-01-16 15:37

Re: Can somebody share difference between big and little end

#12 Post by dezingg »

BowCatShot wrote:So if you have a 2 byte integer containing the value 32766, or 7ffe in hex, a big endian system would store it as fe7f while little endian would store it as 7ffe. Where this matters is when a big endian system is transmitting data to a little endian system. The protocol would have to take that into consideration.
The way I remember it, the issue of big endian vs. little endian came up often when code on PC compatible computers with AMD or Intel processors was being modified to run on Apple computers with Motorola processors.

Now that Apple is using Intel compatible processors, the issue is less likely to come up.
WinXP Compaq Presario overwritten with Wheezy.
WinVista laptop sometimes runs DebianLive. (Hoping to setup a USB HD with persistence.)

Post Reply