posted by surbhi just now
main()
{
float a = 5.375;
char *p;
int i;
p=(char*)&a;
for(i=0;i<=3;i++)
printf("%02x",(unsigned char) p[i]);
}

how is the output of this program is ::

0000ac40

please let me know y this output has come

Answer Posted / sandeep gupta

A very interesting question where u need knowledge of
Computer architecture also.... :) :) :) :)
The floating point(FP) no. are stored differently in memory
as: mantissa × 2^exponent [M× 2^E]. M is 23 bit long and E
is 8 bit. 1 bit is for sign of number. The format is :
SEEE EEEE EMMM MMMM MMMM MMMM MMMM MMMM
Now binary of 5.375 is 101.011 which can be written in
normalized form(which has single 1 before decimal point) as
1.01011 × 2^2. This 1 and point(.) is always neglected while
storing the no. in registers. so mantissa is 01011 or
010110000000000000000000 × 2^E where E is 8 bit(0 to 255).
The actual value of the exponent is calculated by
subtracting 127 from the stored value (0 to 255) giving a
range of –127 to +128.
So here we need E=2 which we can get from 129(129-127=2)
whose binary is: 10000001.
Now above format becomes:
0100 0000 1010 1100 0000 0000 0000 0000 which is 40ac0000 in
hex. So stored format is: 00->00->ac->40

Is This Answer Correct ?    27 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

create a C-code that will display the total fare of a passenger of a taxi if the driver press enter,the timer will stop. Every 10 counts is 2 pesos. Initial value is 25.00

6320


how to create a 3x3 two dimensional array that will give you the sums on the left and bottom columns

3131


why do you use macros? Explain a situation where you had to incorporate macros in your proc report? use a simple instream data example with code ?

2267


Can you send Code for Run Length Encoding Of BMP Image in C Language in linux(i.e Compression and Decompression) ?

3861


Write a routine to implement the polymarker function

4389






How to palindrom string in c language?

8896


Given a spherical surface, write bump-mapping procedure to generate the bumpy surface of an orange

2867


How can I Create a C program in splitting set of characters to specific subsets. Example: INPUT SET OF CHARACTERS: Therefore, my dear brothers and sisters, stand firm. Let nothing move you. Always give yourselves fully to the work of the Lord, because you know that your labor in the Lord is not in vain. SPLIT INTO HOW MANY CHARACTERS PER SUBSETS: 10 OUTPUT: Therefore, my dear b rothers an d sisters, stand fir m. Let not hing move you. Alway s give you rselves fu lly to the work of t he Lord, b ecause you know that your labo r in the L ord is not in vain.

1938


Cluster head selection in Wireless Sensor Network using C programming language.

3118


how to test pierrot divisor

2264


What is the match merge ? compare data step match merge with proc sql merge - how many types are there ? data step vs proc sql

2417


write a program for area of circumference of shapes

2040


Design an implement of the inputs functions for event mode

2970


write a c program to input initial & final time in the format hh:mm and find the time intervel between them? Ex inputs are initial 06:30 final 00:05 and 23:22 final 22.30

2228


#include int main(void) { int a=4, b=2; a=b<>2 ; printf("%d",a); return 0; }

1080