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 1 of 12.
Yerasi Krishna Narasimha Reddy said:
1 year ago
There is an option error.
Actually, the correct one is Option A.
8086 microprocessors store data in hexadecimal.
0100-4.
0000-0.
1010-A.
1100-c.
0000-0.
0000-0.
0000-0.
0000-0.
Actually, the correct one is Option A.
8086 microprocessors store data in hexadecimal.
0100-4.
0000-0.
1010-A.
1100-c.
0000-0.
0000-0.
0000-0.
0000-0.
(3)
Asad Ali said:
4 years ago
Thanks @Avanthika.
(2)
Avanthika said:
5 years ago
Binary equivalent of 5.375 in normalized form is;
0100 -> 4
0000 -> 0
1010 -> A
1100 -> C
0000 -> 0
0000 -> 0
0000 -> 0
0000 -> 0
Since the PC's (Intel processors) use " LITTLE ENDIAN" byte order, the higher-order0 byte of the number is stored in lowest address. The result is written from bottom to top.
0100 -> 4
0000 -> 0
1010 -> A
1100 -> C
0000 -> 0
0000 -> 0
0000 -> 0
0000 -> 0
Since the PC's (Intel processors) use " LITTLE ENDIAN" byte order, the higher-order0 byte of the number is stored in lowest address. The result is written from bottom to top.
(10)
Tamil kudimagan said:
6 years ago
@Tayyaba explain clearly I can't understand.
(1)
Tamil kudimagan said:
6 years ago
@Nikitha explanation is good to compare @Prithi thank you, mam.
(1)
Megha Verma said:
9 years ago
Thank you so much @Shilpa M.Raj. Your explanation is really good and clear.
Raji said:
9 years ago
Thank you so much @Preethi.
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)
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?
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?
Shyam said:
10 years ago
Hi answer is C please any one can explain?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers