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;
}
Discussion:
117 comments Page 8 of 12.
Divya said:
1 decade ago
Preethi is correct.
Hajmal deen said:
1 decade ago
Preethi is correct, but I can't understand, so explain clearly. Please do the needful.
Divya said:
1 decade ago
@ Hajmal
They gave the binary equivalent of 5.375 in normal form
0100 -> 4
0000 -> 0
1010 -> A
1100 -> C
0000 -> 0
0000 -> 0
0000 -> 0
0000 -> 0
They gave the binary equivalent of 5.375 in normal form
0100 -> 4
0000 -> 0
1010 -> A
1100 -> C
0000 -> 0
0000 -> 0
0000 -> 0
0000 -> 0
Malathi said:
1 decade ago
Thank you preethi and pradeep.
Hajmal said:
1 decade ago
Thanks divya.
Ravi ranjan said:
1 decade ago
Preethi is good.
Jisha sankar said:
1 decade ago
Thanks preethi.
Chithra said:
1 decade ago
Thanks preethi and pradeep.
Er.Nitesh mathur said:
1 decade ago
Preethi is wrong because. Defination is given by preethi is totally wrong.
" Big ENDIAN" byte order-> the higher order byte of number is stored in lowest address. The result is written from top to bottom.
" LITTLE ENDIAN"-> byte order, the higher order byte of number is stored in higher address. The result is written from bottom to top.
" Big ENDIAN" byte order-> the higher order byte of number is stored in lowest address. The result is written from top to bottom.
" LITTLE ENDIAN"-> byte order, the higher order byte of number is stored in higher address. The result is written from bottom to top.
Ragini said:
1 decade ago
Thanks preeti.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers