Byte Ordering: Big Endian And Little Endian

December 4, 2010 at 9:41 AM (Technical Articles)

Byte Ordering:

We almost every one know about byte ordering in the underlying architecture . In which order each bit of a data stored in memory ? does tell byte ordering. Of course it is different for different architectures. It become very awkward when a programmer do develop for some other architecture which is not the same as the architecture on which he is developing . It will be something like A right-handed person trying to write with his left hand.

Today I am not going to explain what exactly mean by byte ordering. Instead I am providing a simple definition and two images . some one said that One image is equivalent to Thousand words .  And also some interesting facts on byte ordering.

Endianness: It is the ordering of individually addressable sub-units (words, bytes, or even bits) within a longer data word stored in external memory. (wiki definition ).

Two Types Of Byte Ordering:

1> Big Endian: Underlying architecture stores the least significant byte in the lowest address.

2> Little Endian: Underlying architecture stores the least  significant byte in the highest address.

How they fit in memory?

For better understanding: I am giving an example of C Structure.

Try to understand the image. See the memory layout of a C Structure . Mainly look that character array and one more char variable in memory.


Struct{
 int     a;     //0x1112_1314    word
 double    b;    //0x2122_2324_2526_2728    double word
 char  *c;    //0x3132_3334    Word
 char    d[7];    // ‘A’ ‘B’ ‘C’ ‘D’ ‘E’ ‘F’   ‘G’     byte array
 short    e;    // 0x5152
 int    f;    //0x6162_6364
}S;

Memory Layout :

Endianness

Endianness

See the  memory as a series of array locations:

 

Alternate view of Memory Map

Alternate view of Memory Map

(If Image is not visible clearly, please write click on the image and open it in new tab)

Some interesting facts on Endianess:
1>    Our entire Internet is in big endian format. It means almost all the protocols, APIs are in big endian . And hence writing internet programs on PC makes very awkward. In Windows WinSock provides htoi ( host to internet ) and itoh ( internet to host ) APIs for  necessary conversions.

2>    Java stores its byte code in big endian format , even though the underlying architecture is little endian, a compiled version of a java program, has a byte code in big endian format.

3>    Most of the architectures and network protocols (TCP/IP & UDP mainly ) are big endian . Visit this site for more details :  Please refer table 1 & table 2 in this link. http://www.intel.com/design/intarch/papers/endian.pdf

4>    Even though most of the architecture are in Big endian, why Intel switched to little endian? By the time Intel grown up, most of the network protocols and many other architectures were developed in big endian format. But still intel started its processor manufacturing in little endian. Are there any specific technical reason behind this? I am in search of answer . Help me !!! 🙂

Advertisements

Permalink 5 Comments

Malabar Pit Viper

December 1, 2010 at 8:55 PM (Non Technical)

Trekking became my hobby, exploring new places and enjoying the natural beauty is my interest . I love animals , birds , forest , and I hate the people who pollute such a beautiful places by throwing plastics, bottles ( wine, beer ) and who will shout and disturb the wild animals in forest. So doing trekking became a routine in my life. So far I did 8 trekking , but I was unable to find snakes closely . I did see snakes in few of the trekking and near by my room in udupi while doing jogging ,but I was unable to capture them in my camera. So in every trekking, I was searching for snakes but every time I did end up with a disappointment . But this time It became very happiest moment in my life. Although this is not a trekking , but we did search a lot in forest to see the snakes, and ultimately me and Raj Paban were able to find it while going to KoodluTeertha falls.

Yes We found a very beautiful snake , according to my friend Raj Paban, who has enough knowledge on wild life, it was a  Malabar Pit Viper, found only in western ghats . you can see the images below. I am going to explain you guys about the characteristics of that snake in detail. I got lil information from Raj Paban, and detailed information in Wikipedia also some other sites.

 

PitViper

PitViper

great work by Raj Paban, it is a wonderful snap . I was very happy that moment, I was excited when we were taking the snap, Yes we didn’t disturb it much, It was sleeping 🙂 🙂

Pit Viper:

Biological name: Crotalinea , ( damn sure I can’t remember it 🙂 )
Common Names: Pit vipers
Habitat: Found in Asia and Americas.
Group of snakes which come under this category: Rattlesnakes, Lanceheads , Asian Pitvipers.

Characteristics: They are distinguished by the presence of a heat – sensing pit organ located between the eye and the nostril on either side of the head. It will grow to an average only 30 – 45 cms , Lachesis muta is a species that is known to reach is maximum of 3.65 meters . This is the longest viperid in the world.

They are unique in their own characteristics . A deep pit or Fossa , in the loreal area between the eyes and the nostril on either side of the head. They are extremely sensitive infrared detecting organs, this in effect gives the snakes a sixth sense that helps them to find and perhaps even judge the size of the small warm-blooded prey on which they feed.

When a prey comes into the range, infrared radiations falling onto the pits allows the snakes to determine its direction. Having one of these organs on either side of the head produces a stereo effect that indicates distance as well as direction. When deprived of their senses of sight and smell , these snakes can strike accurately at moving objects that are less than 0.2°C warmer than the background.

Few species are highly active by day , like Green Pit viper ( Link :http://en.wikipedia.org/wiki/Trimeresurus ) , most of them are nocturnal( highly active in the night ). They prefer to avoid scorching( very hot ) daytime temperature . The snakes heat – sensitive pits are also thought to aid in locating cooler areas in which to rest.

They typically wait patiently somewhere for unsuspecting prey to wander by. Studies have indicated that these snakes learn to improve their striking accuracy over time.

Many temperate species ( e.g . Most rattle snakes ) will congregate ( gather in mass ) in shelter area or dense to overwinter , the snakes benefitting from the combined heat, they gather because the mass produces heat, snakes are cold-blooded , usually a many snakes come out for basking (lie exposed to sun light ) on sunny ledges. pit vipers gather in mass to get benefitted from the combined heat, this is unique characteristic of vipers.Like most snakes pitvipers will strike only if cornered or threatened.

Physicist Leo Van Hemmen of the Technical university of Munich in Germany, who is working on finding how heat sensing organs work in pit vipers has said that, these snakes have organs that process images reaching their heat sensors, allowing them to see prey with more clarity than just a warm blob as seen in an infrared. But an amazing skill of vipers made scientists amazed. “ In Lab BlindFolded snakes can strike a running rat behind the ears to avoid its sharp teeth, Says Physicist Leo Van Hemmen “. The pit organs suppose to work as pin hole cameras , except that the holes are too large at 1 millimeter or more in diameter. These must produce images that are just fuzzy blurs. So how can the snake strike with such precision?

Van Hemmen and his team developed a model to study how the snakes process the information reaching their heat sensors. They takes into account both the infrared noise created by moving prey and error generated by the snake’s pit itself. The team recombined the inputs from the 2000 – odd receptors to filter out the noise and create a sharp image. In their model a heat signal reaching each receptor causes a neuron to fire , but the firing rate depends on the input . By tweaking how the receptors interact , the team create precise images, even when there was a lot of background noise. Think guys, they just created a model and were able to produce precise image , it’s just a model, then what about the snake’s organs, a real organ , a god gift? Is it not a great ??? Really it is amazing.

This is all about the Pit vipers. It is a real challenge to scientists to understand, how the pit vipers heat sensing organs work? how can it is possible to the snake to locate its prey? If a typical image processing was taking place in the eyes of the snake, then how can a snake was able to strike the prey when it was blindfolded in lab  ? Technology grows like anything but still we can’t beat the nature, scientists have given many theories on pit vipers , but I still say that, they can’t say with 100% accuracy .The actual technique processed in snakes might be something else, something new to us !!!

See this video , It is not clear but you will get an idea about how snakes capture an image of prey using heat sensing organs and Infrared  . http://www.youtube.com/watch?v=lySW2-eYilg

For all interested people , this will be the best topic for research .

Take a look at wonderful snake once again.

 

PitViper

PitViper

we did also see many butterflies , frogs , wonderful and colorful fungus . totally it was awesome moment , also the KoodluTeertha is very beautiful falls.

 

Butterflies:

1>Chocolate Pancy: http://en.wikipedia.org/wiki/Junonia_iphita

 

ChocolatePancy

ChocolatePancy

2> EggFly: http://en.wikipedia.org/wiki/Hypolimnas_bolina

EggFly

EggFly

3> MalabarNymph: http://en.wikipedia.org/wiki/Idea_malabarica

MalabarNymph

MalabarNymph

Frogs:

1>BlackTorrent: http://en.wikipedia.org/wiki/Micrixalus_saxicola
I have posted something about black torent in my blog on yedakumari trekking : http://is.gd/i31OB

BlackTorrent

BlackTorrent

2> Unknown Frog:

Unknown

Unknown

3> Unknown Frog :

unknown

unknown

Spider:

1> GaintWoodSpider:

GaintWoodSpider

GaintWoodSpider

Fungus: We did see many beautiful fungus there, most of them are Red color , some of them are white color .

Fungus

Fungus

fungus

fungus

fungus

fungus

And finally it is my humble request that please drive slowly in forest area, and stop the road kills , you can save a life .

RoadKill

RoadKill

Our destination:

KoodluTeertha

KoodluTeertha

Photography: Credit goes to Raj Paban .

“Love the nature , save the earth ”

Permalink 8 Comments