C Programming - Floating Point Issues - Discussion
Discussion Forum : Floating Point Issues - General Questions (Q.No. 7)
7.
The binary equivalent of 5.375 is
Discussion:
76 comments Page 2 of 8.
Keerthi said:
1 decade ago
Thanks for clear explanation.
Audhil 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...congrats to surya.......this is d right way......
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...congrats to surya.......this is d right way......
Srini said:
1 decade ago
Why we multiply decimal value *2 ?
Kittu said:
1 decade ago
Because they asked binary equivalent thats why we multiply by 2 .
Vinoth.M said:
1 decade ago
Convert decimal to binary(divide decimal number by 2)
->5/2 quotient=2 remainder=1
->2/2 quotient=1 remainder=0
->1/2 quotient=0 remainder=1
In decimal numbers take remainders from bottom to top so binary equivalent of decimal no 5 is 101
Then take fractional part.Here we can convert fractional no to binary by multiply it by 2
So,->0.375*2=0.750 decimal part=0
->0.750*2=1.50 decimal part=1(omit decimal part)
->0.5*2=1.0 decimal part=1
Here we take decimal part from top to bottom.So binary equivalent of 0.375 is 011
Finally 5.375->101.011
->5/2 quotient=2 remainder=1
->2/2 quotient=1 remainder=0
->1/2 quotient=0 remainder=1
In decimal numbers take remainders from bottom to top so binary equivalent of decimal no 5 is 101
Then take fractional part.Here we can convert fractional no to binary by multiply it by 2
So,->0.375*2=0.750 decimal part=0
->0.750*2=1.50 decimal part=1(omit decimal part)
->0.5*2=1.0 decimal part=1
Here we take decimal part from top to bottom.So binary equivalent of 0.375 is 011
Finally 5.375->101.011
Bharath said:
1 decade ago
I did'tunderstand this can please provide a better solution.
Mrudula said:
1 decade ago
Why should we write only the decimal part from botom to top, it seems some more explanation is need to be there.
Sushmita said:
1 decade ago
In decimal numbers, the digits have values that are powers of ten. Starting at the implied decimal point and working to the left, the number 403 is equal to:
3 x 100 + 0 x 101 + 4 x 102 = 3x1 + 0x10 + 4x100 = 3 + 0 + 400
In binary, the digits have values that are powers of two. Working to the left as before, the number 101 is equal to:
1 x 20 + 0 x 21 + 1 x 22 = 1x1 + 0x2+ 1x4 = (in decimal) 1 + 0 + 4 = 5
So, 1111 1111 = 1x1 + 1x2 + 1x4 + 1x8 + 1x16 + 1x32 + 1x64 + 1x128 = 255.
This also works to the right of the decimal point, but the powers of two are negative (i.e., fractions), so 101.011 in binary is:
1x1/8 + 1x1/4 + 0x1/2 + 1x1 + 0x2 + 1x4 = 5.375
Where the first digit to the right of the decimal point is 2-1 (one-half, or 1/2), the next is 2-2 (1/4), then 2-3 (1/8), etc.
3 x 100 + 0 x 101 + 4 x 102 = 3x1 + 0x10 + 4x100 = 3 + 0 + 400
In binary, the digits have values that are powers of two. Working to the left as before, the number 101 is equal to:
1 x 20 + 0 x 21 + 1 x 22 = 1x1 + 0x2+ 1x4 = (in decimal) 1 + 0 + 4 = 5
So, 1111 1111 = 1x1 + 1x2 + 1x4 + 1x8 + 1x16 + 1x32 + 1x64 + 1x128 = 255.
This also works to the right of the decimal point, but the powers of two are negative (i.e., fractions), so 101.011 in binary is:
1x1/8 + 1x1/4 + 0x1/2 + 1x1 + 0x2 + 1x4 = 5.375
Where the first digit to the right of the decimal point is 2-1 (one-half, or 1/2), the next is 2-2 (1/4), then 2-3 (1/8), etc.
Barun singh said:
1 decade ago
@surya.
Your explanation is nice one.
Your explanation is nice one.
Atul said:
1 decade ago
Thank you surya.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers