C Programming - Floating Point Issues - Discussion

Discussion Forum : Floating Point Issues - General Questions (Q.No. 3)
3.
If the binary eauivalent of 5.375 in normalised form is 0100 0000 1010 1100 0000 0000 0000 0000, what will be the output of the program (on intel machine)?
#include<stdio.h>
#include<math.h>
int main()
{
    float a=5.375;
    char *p;
    int i;
    p = (char*)&a;
    for(i=0; i<=3; i++)
        printf("%02x\n", (unsigned char)p[i]);
    return 0;
}
40 AC 00 00
04 CA 00 00
00 00 AC 40
00 00 CA 04
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
117 comments Page 4 of 12.

Nazia said:   1 decade ago
The format string used for each of the prints is %02X, which I've always interpreted as 'print the supplied int as a hexadecimal value with at least two digits'.

Rahul said:   10 years ago
0100 -> 4
0000 -> 0

1010 -> A
1100 -> C

0000 -> 0
0000 -> 0

0000 -> 0
0000 -> 0

How to convert this why we are using 4, A, C, 0, 0?

Manisha Sehgal said:   1 decade ago
Intel chips are usually Little Endian when it comes to store data in data space. But for storing machine code in code segment the same chip is Big Endian.

Sargam said:   9 years ago
The data type of 'a' is in 'float' but the pointer variable used for that is in 'char'. So is it possible to take float type value in character data type?
(1)

Jitendra jain said:   1 decade ago
I think about this qstn that
it is not well known form
i exicute that in my pc but result come this
but nobody explain me how it work??

Rose said:   1 decade ago
I cant understand the concept clearly anybody explain clearly.

What is big Indian and little Indian?

How to do normalizaton?

Muthulakshmi said:   1 decade ago
How will I understand the c program easily I feel the programs are very difficult. It is easy or not and please teach me.

Suma said:   1 decade ago
@Shilpa m raj.

1.01011*2^2 = 1.01011*100 where 2 is true exponent.

I didn't understand, how *2^2 become *100.

Atul said:   1 decade ago
@Mitesh: Intel processors follow little endian. Big endian is followed by some other vendors like motorola...

Vignesh said:   1 decade ago
Hi, can anyone tell me in what way the given program helps us to find the answer for the given question.


Post your comments here:

Your comments will be displayed after verification.