In: Computer Science
With a detailed step-by-step process, convert the following decimal number into binary, Hexadecimal and IEEE 754 formats :
72.nn ( where nn is 80)
Part 1: convert 72.80 to binary:
Step 1: convert 72(integral part ) to binary:
Division by 2 | Quotient | Remainder |
72/2 | 36 | 0 |
36/2 | 18 | 0 |
18/2 | 9 | 0 |
9/2 | 4 | 1 |
4/2 | 2 | 0 |
2/2 | 1 | 0 |
1/2 | 0 | 1 |
Now write remainder column from down to up it is a binary for 72
(72)10=(1001000)2
Step 2: Convert .80 (fractional part) to binary:
Multiply by 2 | Result | fractional part | Integral part(Binary) |
.80*2 | 1.60 | .60 | 1 |
.60*2 | 1.20 | .20 | 1 |
.20*2 | 0.40 | .40 | 0 |
.40*2 | .80 | .80(Same as first stop) | 0 |
(Note: You may stop multiplication when you get similar number)
Write integral part(Binary) column from up to down. it is a binary equivalent of decimal number
(.80)10 =(1100)2
So Binary equivalent of decimal is:
(72.80)10 =(1001000.1100)2
Part 2: convert 72.80 to Hexadecimal:
Step 1: convert 72(integral part ) to hexadecimal
Division by 16 | Quotient | Remainder->(hexadecimal) |
72/16 | 4 | 8->8 |
4/16 | 0 | 4->4 |
Now write remainder column from down to up it is a hexadecimal for 72
(72)10=(48)16
Step 2 :Convert .80 (fractional part) to hexadecimal:
Multiply by 16 | Result | fractional part | Integral part(hexadecimal) |
.80*16 | 12.8 | .8 | 12 -> C |
.8*16 | 12.8 | .8(Same as first stop) | 12 ->C |
(Note: You may stop multiplication when you get similar number)
Write integral part(hexadecimal) column from up to down. it is a hexadecimal equivalent of decimal number
(.80)10 =(CC)16
So Hexadecimal equivalent of decimal is:
(72.80)10 =(48.CC)16
Part 3: convert 72.80 to IEEE 754 format:
In IEEE 754 we have mainly 3 part
Single precision:
Step 1: Write binary of a decimal mumber
(72.80)10 =(1001000.1100)2
Step 2: Write binary number in a power of 2
1.0010001100 * 26 (26 because we shift decimal by 6)
(0010001100) is calles a normalised mantisa
Sign bit is 0 because number is positive.
Step 3: add 6(power of 2) in actual exponent (127)
127+6=133
Step 4: Conver 133 into binary
(133)10 =(10000101)2
Normalized mantisa is:
0010001100
Step 5 : make 23 bit Normalized mantisa by adding extra 0's
00100011000000000000000
Step 6 :Sign bit is 0
Step 7 : Write Sign, Exponent and mantisa in their format which is the IEEE 754 format
Format is:
Sign(1bit) | Exponent(8bits) | Mantisa(23 bits) |
(0 10000101 00100011000000000000000)
So,
(72.80)10 = (0 10000101 00100011000000000000000) in IEEE 754 format