C Programming - Floating Point Issues - Discussion

Discussion Forum : Floating Point Issues - General Questions (Q.No. 8)
8.
A float occupies 4 bytes. If the hexadecimal equivalent of these 4 bytes are A, B, C and D, then when this float is stored in memory in which of the following order do these bytes gets stored?
ABCD
DCBA
0xABCD
Depends on big endian or little endian architecture
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
36 comments Page 1 of 4.

Abirami said:   2 decades ago
What is 'big endian or little endian architecture'?

Please, give me the correct explanation.

Krunal said:   2 decades ago
"Little Endian" means that the lower-order byte of the number is stored in memory at the lowest address, and the high-order byte at the highest address. For example, a 4 byte Integer

ABCD

will be arranged in memory as follows:
Base Address+0 Byte0
Base Address+1 Byte1
Base Address+2 Byte2
Base Address+3 Byte3

Intel processors (those used in PC's) use "Little Endian" byte order.
"Big Endian" means that the high-order byte of the number is stored in memory at the lowest address, and the low-order byte at the highest address. The same 4 byte integer would be stored as:

Base Address+0 Byte3
Base Address+1 Byte2
Base Address+2 Byte1
Base Address+3 Byte0

Motorola processors (those used in Mac's) use "Big Endian" byte order.

Nishtha said:   2 decades ago
Thank you so much.

Souravb said:   2 decades ago
Thanks dude!!

Harish said:   2 decades ago
Thanks dude :)

Kavita said:   1 decade ago
Krunal was rite about the processors architecture but explanation for Little and Big Endian architecture got reversed.

Here a Proper and Correct Explanation.

Consider the storage of the value ABCD
Here,

A-MSB(Most Significant Byte).
B
C
D-LSB(Least Significant Byte).

In Little Endian Architecture, LSB is at the lowest address of the memory location. Suppose memory location starts with 0
D->0
C->1
B->2
A->3
Intel Processors(CPUs) are Little Endian.

In Big Endian Architecture, MSB is at the lowest address of the memory location. As shown below.
A->0
B->1
C->2
D->3
While Motorola 680x0 CPUs are big-endian

For more details and confirmation visit : http://en.wikipedia.org/wiki/Endianness#Big-endian

Rishabh said:   1 decade ago
@Kavita

Thanks for proper information. Super!

Ram said:   1 decade ago
Good thread guys,
thanks to every one and india bix.

Praveen Kumar said:   1 decade ago
Thank you so much Krunal.

Anusha said:   1 decade ago
Thank you Krunal and Kavitha.

I had a doubt if I had to store 01020304 in little endian, according to ur discription it is 04030201 but why it could not be 40302010 ?


Post your comments here:

Your comments will be displayed after verification.