NUMBER SYSTEMS – PART I ICT1001 – I NTRODUCTION TO ICT L ECTURE 2
2 You will see this icon often in the slides. Click on them to read more information about a certain topic.
INTRODUCTION TO NUMBER SYSTEMS
4 All (if not most) computer deals with numbers in one form or another (e.g. mp3, image, bioinformatics, DNA, weather prediction) Numbering is one of the most important concepts in computer system
Numbers can be represented in many formats Decimal ٠١٢٣٤٥٦٧٨٩ Arabic 〇一二三四五六七八九 Chinese/ Japanese ൦൧൨൩൪൫൬൭൮൯ Malay
6 The decimal system used in our everyday life cannot be efficiently represented in computer
7 Binary numbers are usually used where Instructions, input data and operations carried out in 0 s and 1 s 01
8 We need to also perform operations on real/floating numbers ( +, -, ×, ÷ precision)
POSITIONAL NUMBER SYSTEM 9
The number system we use is a positional system. Each digit position has an associated weight: It means = 2× × × ×10 0 For example The weight of each digit is a power of 10, increasing to the left. This represents decimal system
11 The decimal number system we use is a radix 10 positional system : each digit position has an associated weight: = 3× × × × × ×10 -2 the weight of each digit is a power of 10, increasing to the left. A decimal point allows for negative powers:
12 In general, a number of the form “d 3 d 2 d 1 d 0.d - 1 d -2 ” in radix 10 positional system has the value: = d 3 × d 2 × d 1 × d 0 × d -1 × d -2 ×10 -2 RADIX 10
13 Similarly, a number of the form “d 3 d 2 d 1 d 0.d -1 d -2 ” in radix 2 positional system has the value: = d 3 ×2 3 + d 2 ×2 2 + d 1 ×2 1 + d 0 ×2 0 + d -1 × d -2 ×2 -2 RADIX 2
14 RADIX r
EXAMPLE – RADIX 2 15
16 Digital circuits can only represent two values: on and off, high and low, or 1 and 0. Numbers are represented by binary digits (bits) which can have a value of either 1 or Most Significant Bit (MSB) Least Significant Bit (LSB)
17 NUMBER CONVERSION What is in decimal?
= 1×8 + 1×4 + 0×2 + 1×1 = = 1× ×64 + 0×32 + 1×16 + 1×8 + 1×4 + 0×2 + 0×1 = = 1×8 + 1×4 + 0×2 + 1×1 + 0× × ×0.125 = More examples:
NUMBER CONVERSION 19 An n-bit unsigned binary number can represent values from 0 to +(2 n -1) e.g. an 4-bit binary number can represent values from 0 to bit binary number
20 The powers of two are everywhere in digital design, so learn them as you work: 1 (2 0 ), 2 (2 1 ), 4 (2 2 ), 8 (2 3 ), 16 (2 4 ), 32 (2 5 ), 64 (2 6 ), 128 (2 7 ), 256 (2 8 ), 512 (2 9 ), 1024 (2 10 ), …
21 To speed up conversion, please learn how to convert using calculator (only non-programmable digital calculators are allowed) Link:
CONVERSION ALGORITHM 22 Divide by 2 Record quotient (Q) and remainder R Is Q=0 ? Collect R’s into desired binary number with first R as LSB and last R as MSB End Start Yes No Examples: ÷ 2 = 56 remainder 1 (LSB) ÷ 2 = 28 remainder ÷ 2 = 14 remainder ÷ 2 = 7 remainder ÷ 2 = 3 remainder ÷ 2 = 1 remainder ÷ 2 = 0 remainder 1 (MSB) = MSB LSB
23 HEX REPRESENTATION Binary digits for large numbers are long and tedious to write and remember Hexadecimal representation is usually used
24 HEXADECIMAL IS RADIX 16 0, 1, 2, 3, …, 8, 9, A, B, C, D, E, F These are the symbols used in Hexadecimal system
HEX CONVERSION 25 One hex digit equals four binary digits (since 2 4 = 16). Hence conversion is very simple. We arrange binary digits in groups of 4: B9F 16 = B 9 F
26 Hex representation is widely used for memory address and data. memory address
27 BinaryDecimalHex A B C D E F This table shows binary, and hex representation for values from 0 to 15.
28 KNOWLEDGE CHECK TIME! Please attempt a quiz on LMS
29 Why 15? An n-bit unsigned binary number can represent values from 0 to +(2 n -1) A 4-bit unsigned binary number can represent values from 0 to +(2 4 -1)= 15 BACK
30 How do you understand this diagram? In the example in the slide it says: an 4-bit binary number can represent values from 0 to 15. So in the diagram you can see that value from 0 to 15 are representable. Values greater than 15 are not representable, we say it is “Overflow”. BACK
31 Examples: ÷ 2 = 56 remainder 1 (LSB) ÷ 2 = 28 remainder ÷ 2 = 14 remainder ÷ 2 = 7 remainder ÷ 2 = 3 remainder ÷ 2 = 1 remainder ÷ 2 = 0 remainder 1 (MSB) = MSB LSB In this example, we convert 113 in decimal into binary representation. First, divide 113 by 2, we get 1 as the remainder. Continue this step until we have 1 divide by 2, which gives 0 as the quotient. This is when we STOP. The last remainder is the first digit (most significant bit) in the binary representation. Try other example to practice this conversion. BACK
32 Why 1101 is B in hexadecimal? To understand why, first, convert 1101 to decimal 1101 = 1x8 + 1x4 + 0x2 + 1 = in decimal is B in hexadecimal BACK