Converting Decimal to Binary and 2's Complement Representation
1. How do you convert the decimal number 149 to simple binary? 2. How do you convert the numbers +121 and -121 to 2's complement 8-bit binary numbers?
To convert the decimal number 149 to simple binary, we divide the number repeatedly by 2 until the quotient becomes 0. The remainders obtained in each division, read in reverse order, give us the binary representation. Here's the calculation: 149 ÷ 2 = 74 (remainder 1) 74 ÷ 2 = 37 (remainder 0) 37 ÷ 2 = 18 (remainder 1) 18 ÷ 2 = 9 (remainder 0) 9 ÷ 2 = 4 (remainder 1) 4 ÷ 2 = 2 (remainder 0) 2 ÷ 2 = 1 (remainder 0) 1 ÷ 2 = 0 (remainder 1) Reading the remainders in reverse order, the binary representation of 149 is 10010101. To convert the numbers +121 and -121 to 2's complement 8-bit binary numbers: a) +121 in simple binary: 121 ÷ 2 = 60 (remainder 1) 60 ÷ 2 = 30 (remainder 0) 30 ÷ 2 = 15 (remainder 0) 15 ÷ 2 = 7 (remainder 1) 7 ÷ 2 = 3 (remainder 1) 3 ÷ 2 = 1 (remainder 1) 1 ÷ 2 = 0 (remainder 1) Reading the remainders in reverse order, the simple binary representation of +121 is 01111001. b) -121 in 2's complement 8-bit binary: First, we represent the absolute value of -121 in simple binary: 121 ÷ 2 = 60 (remainder 1) 60 ÷ 2 = 30 (remainder 0) 30 ÷ 2 = 15 (remainder 0) 15 ÷ 2 = 7 (remainder 1) 7 ÷ 2 = 3 (remainder 1) 3 ÷ 2 = 1 (remainder 1) 1 ÷ 2 = 0 (remainder 1) The simple binary representation of 121 is 01111001. To obtain the 2's complement representation of -121, we invert the bits (changing 0s to 1s and 1s to 0s) and add 1 to the least significant bit. Inverting the bits: 10000110 Adding 1: 10000111