In: Computer Science
Assuming integers are represented as 32-bit words and negative numbers are represented using the 2's complimentary method convert the following decimal numbers to hexadecimal numbers (show your work). a. -1314, b. 2020
Hexadecimal Binary 0 0000 1 0001 2 0010 3 0011 4 0100 5 0101 6 0110 7 0111 8 1000 9 1001 A 1010 B 1011 C 1100 D 1101 E 1110 F 1111 using this table for converting binary to hexadecimal a) This is negative. so, follow these steps to convert this into a 2's complement binary Step 1: Step 1. Divide 1314 successively by 2 until the quotient is 0 1314/2 = 657, remainder is 0 657/2 = 328, remainder is 1 328/2 = 164, remainder is 0 164/2 = 82, remainder is 0 82/2 = 41, remainder is 0 41/2 = 20, remainder is 1 20/2 = 10, remainder is 0 10/2 = 5, remainder is 0 5/2 = 2, remainder is 1 2/2 = 1, remainder is 0 1/2 = 0, remainder is 1 Read remainders from the bottom to top as 10100100010 So, 1314 in normal binary is 00000000000000000000010100100010 Step 2: flip all the bits 00000000000000000000010100100010 is flipped to 11111111111111111111101011011101 Step 3:. Add 1 to above result 11111111111111111111101011011101 + 1 = 11111111111111111111101011011110 so, -1314 in 2's complement binary is 11111111111111111111101011011110 11111111111111111111101011011110 in hexadecimal is 0xFFFFFADE Answer: 0xFFFFFADE b) Since this is a positive number. we can directly convert this into binary Step 1. Divide 2020 successively by 2 until the quotient is 0 2020/2 = 1010, remainder is 0 1010/2 = 505, remainder is 0 505/2 = 252, remainder is 1 252/2 = 126, remainder is 0 126/2 = 63, remainder is 0 63/2 = 31, remainder is 1 31/2 = 15, remainder is 1 15/2 = 7, remainder is 1 7/2 = 3, remainder is 1 3/2 = 1, remainder is 1 1/2 = 0, remainder is 1 Read remainders from the bottom to top as 11111100100 so, 2020 in 2's complement binary is 00000000000000000000011111100100 00000000000000000000011111100100 in hexadecimal is 0x000007E4 Answer: 0x000007E4