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 3 of 12.
Sirisha said:
1 decade ago
p=(char *)&a;
satish i thik (char*)this is for type casting as
a is float and p is char
satish i thik (char*)this is for type casting as
a is float and p is char
Shiva said:
1 decade ago
Thanks preethi...!
Nnnn bbbbb said:
1 decade ago
How do we decide whether to use big endian or small endian?
Pramod Jarhad said:
1 decade ago
I think preethi is correct.
Lordy said:
1 decade ago
Didn't understand even. Please explain further.
Abhi17188@gmail.com said:
1 decade ago
If little endian prints from bottom to top, then why D is not correct.
Dhirendra said:
1 decade ago
@satish & @megha : in exp p=(char *)&a;
p is a pointer of type char and a is a interger but a pointer is always of type unsigned constant interger so what we are doing is typecasting the address so that so that the compatability remains........
p is a pointer of type char and a is a interger but a pointer is always of type unsigned constant interger so what we are doing is typecasting the address so that so that the compatability remains........
Muthu said:
1 decade ago
Preethi answer is good.
Amit said:
1 decade ago
Why it is c? why not d?
Anusha said:
1 decade ago
@amith: the ans is C bcoz it is considered byte wise
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers