Professional Documents
Culture Documents
CS101 Assignment No 1 Solution Fall 2020
CS101 Assignment No 1 Solution Fall 2020
Assignment no. 1
Fall 2020
Assignment Question: -
Convert the following decimal numbers into equivalent binary numbers and then convert the
binary answer back into equivalent decimal.
• 4789
• -8735
Solution:
1. Conversion of 4789
❖ Decimal to Binary:
2 4789
2 2394 ____ 1
2 1197 ____ 0
2 598 _____ 1
2 299 _____ 0
2 149 _____ 1
2 74 ______ 1
2 37 ______ 0
2 18 ______ 1
2 9 _______ 0
2 4 _______ 1
2 2 _______ 0
1 _______ 0
⇒ (𝟒𝟕𝟖𝟗)𝟏𝟎 = ( 𝟏𝟎𝟎𝟏𝟎𝟏𝟎𝟏𝟏𝟎𝟏𝟎𝟏 )𝟐
❖ Binary to decimal:
𝟐𝟏𝟐 𝟐𝟏𝟏 𝟐𝟏𝟎 𝟐𝟗 𝟐𝟖 𝟐𝟕 𝟐𝟔 𝟐𝟓 𝟐𝟒 𝟐𝟑 𝟐𝟐 𝟐𝟏 𝟐𝟎
4096 2048 1024 512 256 128 64 32 16 8 4 2 1
1 0 0 1 0 1 0 1 1 0 1 0 1
********************************
2. Conversion of -8735
❖ Decimal to Binary
2 8735
2 4367 _____ 1
2 2183 _____ 1
2 1091 _____ 1
2 545 ______ 1
2 272 ______ 1
2 136 ______ 0
2 68 _______ 0
2 34 _______ 0
2 17 _______ 0
2 8 ________ 1
2 4 ________ 0
2 2 ________ 0
1 ________ 0
⇒ ( 𝟖𝟕𝟑𝟓 )10 = ( 𝟏𝟎𝟎𝟎𝟏𝟎𝟎𝟎𝟎𝟏𝟏𝟏𝟏𝟏 )2
❖ 𝐁𝐢𝐧𝐚𝐫𝐲 𝐭𝐨 𝐃𝐞𝐜𝐢𝐦𝐚𝐥
𝟐𝟏𝟑 𝟐𝟏𝟐 𝟐𝟏𝟏 𝟐𝟏𝟎 𝟐𝟗 𝟐𝟖 𝟐𝟕 𝟐𝟔 𝟐𝟓 𝟐𝟒 𝟐𝟑 𝟐𝟐 𝟐𝟏 𝟐𝟎
8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1
1 0 0 0 1 0 0 0 0 1 1 1 1 1
***************************