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 5 of 12.
Well wisher said:
1 decade ago
Preethi's explanation is reall good.
Some asked why not D ?.
If you see the things.
0102
02 is in separate address.
O1 is in very next address.
In case of little endian.
To know what exactly happens refer to some microprocessor book it will give you a clear idea.
Some asked why not D ?.
If you see the things.
0102
02 is in separate address.
O1 is in very next address.
In case of little endian.
To know what exactly happens refer to some microprocessor book it will give you a clear idea.
Raji said:
1 decade ago
Thanks preethi.
Vinay said:
1 decade ago
Vishal pandey is correct but how you can normalised the last address p[3]=00000000 10000000 as 40.
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?
What is big Indian and little Indian?
How to do normalizaton?
Atul said:
1 decade ago
@Mitesh: Intel processors follow little endian. Big endian is followed by some other vendors like motorola...
Vinoth said:
1 decade ago
I am also same doubt as Shweta. Why we take every two bits rather than 1 bit.
Satti said:
1 decade ago
Satish, p declared as a character pointer,so a is not a character type. so we can covert a type to p char type.
char *p;
int i=10;
p=(char*)i;// type casting is done.
char *p;
int i=10;
p=(char*)i;// type casting is done.
Arun said:
1 decade ago
VISHAL explanation is fine.
Kiran chowdary said:
1 decade ago
I agree with preeti, but can u tell me where we use this.
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??
it is not well known form
i exicute that in my pc but result come this
but nobody explain me how it work??
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers