Special Lecture Exercise for Lec02 (CS1102 - Section C01/CB1/CC1) www.cs.cityu.edu.hk/~helena Casual Discussion, Warm-up Questions, and Lecture Demo Exercises 1. Complete the following table to show the conversion between four number systems: Decimal [Base 10] Digits: 0-9 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Binary [Base 2] Octal [Base 8] Digits: 0,1 Digits: 0-7 0 1 10 11 100 101 110 111 1000 1001 1010 1011 1100 1101 1110 0 1 2 3 4 5 6 7 10 11 12 13 14 15 Hexadecimal [Base 16] Digits: 0-9,A,B,C,D,E,F 0 1 2 3 4 5 6 7 8 9 A B C 2. (i) Complete the table on the right which shows the powers of 2: (ii). Fill in the blanks: (a) 0 1 0 0 0 0 1 1 (2) = __________________(10) (b) 1 1 1 1 0 0 1 1 (2) = __________________(16) (c) 1 1 0 1 0 0 1 1 (2) = __________________(8) 20 21 22 23 24 25 26 27 28 29 210 =1 =2 =4 =8 = = = = = = = 3. Why are followings most commonly used? Number System Reason to use (Base 2) Binary - 2 digits: 0,1 (Base 8) Octal - 8 digits: 0-7 (Base 10) Decimal - 10 digits: 0-9 (Base 16) Hexadecimal - 16 digits: 0-9,A-F 1 Special Lecture Exercise for Lec02 (CS1102 - Section C01/CB1/CC1) 4. Choose "Least significant" or "Most significant" to describe each underlined digit: Note: significant means "important" www.cs.cityu.edu.hk/~helena I have $375.15 Most / least significant digit Most / least significant digit 5. Consider using 2's complements to represent a range of -ve to + ve numbers If we use 4 bits to represent a range of numbers in 2's complement, they can be -8(10) to 7(10) If we use 8 bits to represent a range of numbers in 2's complement, they can be -128(10) to ____(10) In 2's complement, The left-most bit is always __. 6. Summary / More practices on Binary Arithmetic What you learnt More Examples, Practices [Slide 9] Conversion from Decimal to Binary (Whole numbers) Repeated division (a) 26(10) = _____________(2) [Slide 22] Binary Addition (note: carry digits) [Slide 22] Binary Subtraction (note: borrow digits) [Slide 23] Binary Multiplication [Slide 23] Binary Division [Slide 27-32] To deal with -ve numbers Using Two's Complement (b) 0011(2) +0101(2) = ____________(2) (c) 1001(2) -0011(2) = ____________(2) (d) 101(2) x 110(2) = ____________(2) (e) 111000(2) / 110(2) = _____________(2) (f) 5 - 2 = _____________(2) 2
© Copyright 2026 Paperzz