C Programming - Floating Point Issues - Discussion

Discussion Forum : Floating Point Issues - General Questions (Q.No. 7)
7.
The binary equivalent of 5.375 is
101.101110111
101.011
101011
None of above
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
76 comments Page 4 of 8.

Ajinkya said:   1 decade ago
For converting any Decimal Number to its equivalent Binary Number:

1) For the Integer part of the Number(Before Decimal Point):

Divide that Number by 2 (Eg. 5%2) till the quotient is 1 and note down the remainders in each division (either 0 or 1). When you reach 1, then stop and in the Remainder column, write 1 at the bottom. Then, for your integer part answer, write it from bottom to top.

2) For the Decimal part of the Number(After Decimal Point):

Multiply that Number by 2 (Eg. 0.375*2) till the answer reaches 1. But when you multiply by 2, remove the integer part of the answer and write it down in one column and then multiply the decimal part of the answer by 2 till you reach 1. And when you reach 1, then stop and your answer will be in the same order as that of the numbers that you had written in the column mentioned above.

Eg.) 5.375 : Ans.) 101.011

1) Firstly, integer part is : 5

So,
Remainder
5/2 = 1 (Bottom-Top Approach)
2/2 0
1 1
(As 1 is reached, STOP!!!)

Hence, Binary Equivalent of 5 = 101

2) Now for the Decimal Part: 0.375

Multiplication Answer
0.375*2 = 0.75 0 (Top-Bottom Approach)
0.75*2 = 1.50 1
0.50*2 = 1.00 1
(As 1 is reached, STOP!!!)

Hence, Binary Equivalent of 0.375 = 0.011

Therefore, Binary Equivalent of 5.375 = 101.011.

Hope this helps... :).
Keep Posting....

Vishal said:   1 decade ago
5.375

5 --> 101

0.375 * 2 = 0.75
0.75 * 2 = 1.5
0.5 * 2 = 1.0

Consider,only the decimal part from top to bottom ( 0 1 1)
THEREFORE, 5.375=101.011

Ankit said:   1 decade ago
5 is equivalent to 101. The main problem is relate with floating points values.
0.375*2
0.750*2=write the digit left to the decimal point i.e.=0
1.500*2=write the digit left to the decimal point i.e.=1
0.500*2=write the digit left to the decimal point i.e.=1
1.000
Now combine the binary values:
(5.375)base 10=(101.011)base 2

Meera said:   1 decade ago
5.375
5/2 remainder is 1
2/2 remainder is 0
1/2 remainder is 1
bottom up---> 101
.375 * 2= 0.75 number without decimal point is 0
.75 * 2= 1.5 number without decimal point is 1
.5*2 =1 number without decimal point is 1
After reaching 1 stop it .
now it is top down ----->011
Hence the answer is 101.011

Firdous Sadaf Mohd Ismail said:   1 decade ago
5.375
first convert 5 into binary as
(5/2)=quotient(2) and remainder (1)
(2/2)=quotient(1) and remainder (0)
(1/1)=quotient(1) and remainder (1)
therefore 5 = 101 (write remainder from bottom to top)

Now covert 0.375 into binary as
0.375 * 2 = 0 .75
0.75 * 2 = 1 .5
0.5 * 2 = 1 .0
(write remainder from top to bottom)

Therefore the answer is 5.375=101.011

Sai said:   1 decade ago
5.375

5 --> 101

0.375 * 2 = 0.75
0.75 * 2 = 1.5
0.5 * 2 = 1.0

Consider,only the decimal part from top to bottom ( 0 1 1)
THEREFORE, 5.375=101.011

Subbu.B said:   1 decade ago
Thank you Surya and Susmita.

Sibinxavier said:   1 decade ago
After "." it become

111= 1/2,1/4,1/8

375
011 = 0*(1/2)+1(1/4)+1(1/8)
=.25+.125 =.375
5.375 =101.011

RENU said:   1 decade ago
5.375
5=101

0.375
*2
____________=0
0.750
*2
____________=1
1.500

0.500
*2
____________=1

so 5.375=101.011
that is B

Mohit said:   1 decade ago
If the size of integer is 4bytes, What will be the output of the program?

How we can examine this type of question?


Post your comments here:

Your comments will be displayed after verification.