🎧 New: AI-Generated Podcasts Turn your study notes into engaging audio conversations. Learn more

Chapter 1 - Number Systems.pdf

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Document Details

SpellboundMercury

Uploaded by SpellboundMercury

Tags

binary system number systems mathematics computing

Full Transcript

CHAPTER 1.1 0101110? AE73F9? Number System Binary System Motivation Why Binary System 1. Computers consist of millions of tiny switches that can be either on or off. 2. All information must be...

CHAPTER 1.1 0101110? AE73F9? Number System Binary System Motivation Why Binary System 1. Computers consist of millions of tiny switches that can be either on or off. 2. All information must be transformed into binary format to be processed by a computer. 3. Therefore, the binary system is selected as the method for computers to represent any type of data. On = 1 Off = 0 Explanation Denary System Eg. 365 2 10 =100 10 1 =10 10 0 =1 3 6 5 Explanation: Multiply the digit value (eg.3) by the place value (eg. 100) (3x100) + (6x10) + (5x1) = Explanation Binary Denary Denary Binar y Binar Denary Explanation y 2 2 =4 2 1 =2 2 0 =1 1 1 1 (1x4) + (1x2) + (1x1) = 7 in denary Binar Denary Explanation y Eg. "1011" 3 2 =8 2 2 =4 2 1 =2 2 0 =1 1 0 1 1 Explanation: Multiply the digit value (eg.1) by the place value (eg. 8). Then sum it all up! (1x8) + (0x4) + (1x2) + (1x1) = 11 in denary Denary Binar (Method Explanation y 1) Convert 5 to binary: 4 2 1 1 1 0 0 Denary Binar (Method Explanation y 1) Convert 5 to binary: 4 2 1 1 -1= 1 0 1 1 Denary Binar DIY y What is the binary form of 15? Denary Binar DIY y ANSWER 2 3 =8 2 2 =4 2 1 =2 2 0 =1 1 1 1 1 Denary Binar Explanation y Convert 5 to binary: 5 5 2 2 remainder 1 2 1 remainder 0 Read the remainder from bottom to top 2 0 remainder 1 Answer: 101 Denary Binar Explanation y Convert 39 to binary: 39 2 19 1 39 remainde 2 9 r remainde 1 2 4 r remainde 1 Read the remainder 2 2 r remainde 0 from bottom to top 2 1 r remainde 0 2 0 r remainde 1 r Answer: 100111 Denary Binar DIY y What is the binary form of 42? 2 5 =32 2 4 =16 3 2 =8 2 2 =4 2 1 =2 2 0 =1 Denary Binar DIY y ANSWER Convert 42 to binary: 42 2 2 0 42 remainde 2 10 r remainde 1 2 15 r remainde 0 Read the remainder 2 2 r remainde 1 from bottom to top 2 1 r remainde 0 2 0 r remainde 1 r Answer: 101010 RECAP Denary System 10 2 10 1 10 0 (7x100) + (6x10) 7 6 5 + (5x1) = 765 Hundredth Tenth Ones RECAP Denary System 10 2 10 1 10 0 (7x100) + (6x10) 7 6 5 + (5x1) = 765 Binary System 2 2 21 20 (1x4) + (1x2) 1 1 1 + (1x1) = 7 Binar Denary DIY y What is the denary form of "1010"? 3 2 =8 2 2 =4 2 1 =2 2 0 =1 1 0 1 0 Binar Denary DIY y ANSWER 3 2 =8 2 2 =4 2 1 =2 2 0 =1 1 0 1 0 (1x8) + (1x2) = 10 in denary Denary Binar DIY y What is the binary form of 38? 2 5 =32 2 4 =16 3 2 =8 2 2 =4 2 1 =2 2 0 =1 Denary Binar (Method DIY y 2) ANSWER Convert 38 to binary: 38 2 1 0 38 remainde 2 9 r remainde 1 2 9 4 r remainde 1 Read the remainder 2 2 r remainde 0 from bottom to top 2 1 r remainde 0 2 0 r remainde 1 r Answer: 100110 PAST YEAR QUESTION ANSWER Hexadecimal System Hexadecimal System Motivation It is a base 16 system. It uses 16 digits to represent each value Number System Digits used to represent each value Denary 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Binary 0, 1 Hexadecimal 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 , A, B, C, D, E, F Hexadecimal System Explanation Denary System Binary System 1 10 =100 10 =10 10 =1 2 0 2 2 =4 2 1 =2 2 0 =1 3 6 5 1 0 1 (3x100) + (6x10) + (5x1) = (1x4) + (0x2) + (1x1) = 5 365 Hexadecimal System ? 2 =? ? 1 =? ? 0 =? 3 E 5 Hexadecimal System Explanation Denary System Binary System 1 10 =100 10 =10 10 =1 2 0 2 2 =4 2 1 =2 2 0 =1 3 6 5 1 0 1 (3x100) + (6x10) + (5x1) = (1x4) + (0x2) + (1x1) = 5 365 Hexadecimal System 16 2 =256 16 1 =16 16 0 =1 3 E 5 Conversion Binary Hexadecima l Hexadecima Binar l y Binar Hexadecima Explanation l y 4 Since 16 = 2 this means that FOUR binary digits are equivalent to each hexadecimal digit. Binary Hexadecimal Binary Hexadecimal 0 0 0 0 0 1 0 0 0 8 0 0 0 1 1 1 0 0 1 9 0 0 1 0 2 1 0 1 0 A 0 0 1 1 3 1 0 1 1 B 0 1 0 0 4 1 1 0 0 C 0 1 0 1 5 1 1 0 1 D 0 1 1 0 6 1 1 1 0 E 0 1 1 1 7 1 1 1 1 F Binar Hexadecimal Explanation y 10111110000 Binary to Hexadecimal Conversion Table 1 0 0 0 0 0 0 0 1 0 1 1 1 0 0 0 0 0 1 8 9 101 1 111 0 0 0 01 0 0 1 0 2 1 0 1 0 A 0 0 1 1 3 1 0 1 1 B 0 1 0 0 4 1 1 0 0 C 0 1 0 1 5 1 1 0 1 D B E 1 0 1 1 0 6 1 1 1 0 E 0 1 1 1 7 1 1 1 1 F ANSWER : BE1 Binar Hexadecima Explanation l y 10 00011111110 Binary to Hexadecimal Conversion Table 1 0 0 0 0 0 1 0 0 0 8 00 10 0001 1111 1101 0 0 0 0 0 1 1 0 1 2 1 1 0 0 0 1 1 0 9 A 0 0 1 1 3 1 0 1 1 B 0 1 0 0 4 1 1 0 0 C 0 1 0 1 5 1 1 0 1 D 2 1 F D 0 1 1 0 6 1 1 1 0 E 0 1 1 1 7 1 1 1 1 F ANSWER : Binar Hexadecimal DIY y Binary to Hexadecimal What is the hexadecimal form of Conversion Table 0111010011100? 0 0 0 0 0 1 0 0 0 8 0 0 0 1 1 1 0 0 1 9 0 0 1 0 2 1 0 1 0 A 0 0 1 1 3 1 0 1 1 B 0 1 0 0 4 1 1 0 0 C 0 1 0 1 5 1 1 0 1 D 0 1 1 0 6 1 1 1 0 E 0 1 1 1 7 1 1 1 1 F Binar Hexadecima DIY l y ANSWER 011101001110 Binary to Hexadecimal Conversion Table 0 0 0 0 0 0 1 0 0 0 8 0 0 0 1 1 1 0 0 1 0000 1110 1001 1100 9 0 0 1 0 2 1 0 1 0 A 0 0 1 1 3 1 0 1 1 B 0 1 0 0 4 1 1 0 0 C 0 1 0 1 5 1 1 0 1 D 0 1 1 0 6 1 1 1 0 E 0 1 1 1 7 1 1 1 1 F 0 E 9 C Hexadecima Binar Explanation l y F 9 3 5 Binary to Hexadecimal Conversion Table 0 0 0 0 0 1 0 0 0 8 111 001 010 0 0 0 1 1 1 0 0 1 9 1 100 1 1 0 0 1 0 2 1 0 1 0 A 1 0 0 1 1 3 1 0 1 1 B 0 1 0 0 4 1 1 0 0 C 0 1 0 1 5 1 1 0 1 D 0 1 1 0 6 1 1 1 0 E Answer: 111 100 001 010 0 1 1 1 7 1 1 1 1 F 1 1 1 1 Hexadecimal Binar DIY y Binary to Hexadecimal What is the binary form of Conversion Table BF08? 0 0 0 0 0 1 0 0 0 8 0 0 0 1 1 1 0 0 1 9 0 0 1 0 2 1 0 1 0 A 0 0 1 1 3 1 0 1 1 B 0 1 0 0 4 1 1 0 0 C 0 1 0 1 5 1 1 0 1 D 0 1 1 0 6 1 1 1 0 E 0 1 1 1 7 1 1 1 1 F Hexadecima Binar DIY l y B F 0 8 Binary to Hexadecimal Conversion Table 0 0 0 0 0 1 0 0 0 8 101 000 100 0 0 0 1 1 1 0 0 1 9 1 111 0 0 0 0 1 0 2 1 0 1 0 A 1 0 0 1 1 3 1 0 1 1 B 0 1 0 0 4 1 1 0 0 C 0 1 0 1 5 1 1 0 1 D 0 1 1 0 6 1 1 1 0 E Answer: 101 111 000 100 0 1 1 1 7 1 1 1 1 F 1 1 0 0 Conversion Hexadecima Denar l y Denary Hexadecima l Binar Denary RECAP y Eg. "111" 2 2 =4 2 1 =2 2 0 =1 1 1 1 (1x4) + (1x2) + (1x1) = 7 in denary Hexadecima Denar Explanation l y Eg. "45A" 16 2 =256 16 1 =16 16 0 =1 4 5 A Note: A=10 (4x256) + (5x16) + (10x1) = 1114 in denary Hexadecimal Denar Explanation y Eg. "C8F" 16 2 =256 16 1 =16 16 0 =1 C 8 F Note: C=12, F=15 (12x256) + (8x16) + (15x1) = 3215 in denary Hexadecimal Denar DIY y What is the denary form of BF08? 16 3 =4096 16 2 =256 16 1 =16 16 0 =1 B F 0 8 Hexadecimal Denar DIY y ANSWER 16 3 =4096 16 2 =256 16 1 =16 16 0 =1 B F 0 8 (11x4096) + (15x256) + (0x16) + (8x1) = 48904 in denary Denary Binar (Method RECAP y 2) Convert 5 to binary: 5 5 2 2 remainde 1 Read the remainder 2 1 r remainde 0 from bottom to top 2 0 r remainde 1 r Answer: 101 Denar Hexadecimal Explanation y Eg. "2004" 2004 /16 =125 remainder = 4 200 1 12 4 remainde 4 1 6 7 5 r remainde 1 125/16 = 7 1 0 r 7 6 remainde remainder = 13 r 3 6 Note: 13=D Answer: Denar Hexadecimal DIY y What is the hexadecimal form of 3179? 3179 /16 = ? 317 1 19 9 remainde ? 1 6 ? 8 r remainde ? 1 ? r ? 6 remainde r 6 Denar Hexadecimal DIY y What is the hexadecimal form of 3179? 3179 /16 = 198 remainder = 11 317 1 19 9 remainder 1 198/16 = 12 1 1 6 6 8 remainder 1 remainder = 6 1 0 2 1 6 remainder 6 2 Answer: PAST YEAR QUESTION ANSWER PAST YEAR QUESTION ANSWER Use of hexadecimal system Use of hexadecimal Discussion Time system Binary Hexadecimal 110101111110 1AFD39 100111001 Why is Hexadecimal used? Use of hexadecimal Discussion Time system Binary Hexadecimal 110101111110 1AFD3 100111001 Why is Hexadecimal used? 9 Answer: Easier to read/write Use fewer characters Less likely to make mistakes. Use of hexadecimal Explanation system 1. One hex digit represents four binary digits. 2. The hex number is far easier for humans to remember, copy and work with. Usage 1: Error Code Explanation 1. Error codes are often shown as hexadecimal values. 2. These numbers refer to the memory location of the error. 3. They are generated by the computer. 4. The programmer needs to know how to interpret the hexadecimal error codes. Usage 1: Error Code Explanation Usage 2: MAC address Explanation 1. A Media Access Control (MAC) address is a unique identifier assigned to a device on a network. 2. It is linked to the network interface card (NIC) within the device. 3. The MAC address is seldom altered, allowing the device to be consistently recognized regardless of its location. Usage 2: MAC address Explanation 00_1C_B3_4F_25_FE 00_1C_C3_4F_23_AE Usage 2: MAC address Explanation Form 1 NN-NN-NN-DD-DD-DD 00-1C-B3-4F-25-FE Form 2 NN:NN:NN:DD:DD:DD 00:1C:B3:4F:25:FE Usage 2: MAC address Explanation 00-1C-B3 4F-25-FE Identity number of Identity of device the manufacturer 00 – 14 – 22 which identifies devices made by Dell 00 – a0 – c9 which identifies devices made by Intel Usage 2: MAC address Explanation Usage 3: Internet Protocol Addresses Explanation 1. Every device connected to a network is assigned an Internet Protocol (IP) address. 2. An IPv4 address is a 32-bit number, typically written in decimal or hexadecimal format, such as 128.65.152.11 (or 80.41.98.0b in hexadecimal). 3. Recently, IPv4 has been enhanced with the introduction of IPv6, which uses a 128-bit number divided into 16-bit segments and represented in hexadecimal format. Usage 3: HyperText Markup Language (HTML) colour code Explanation 1. HyperText Mark-up Language (HTML) is used when writing and developing web pages. 2. It is not a programming language, but a markup language. 3. A mark-up language is used in the processing, definition and presentation of text. PAST YEAR QUESTION ANSWER PAST YEAR QUESTION ANSWER Chapter 1.3 Addition of binary number Addition of binary number Explanation How do we perform add and carry in denary? 0+0=0 1 9 0+9=9 +1 9+0=9 10 9 + 1 = 10 Addition of binary number Explanation How do we perform add and carry in denary? 1 1 56 6+9 = 15 1+5+7 (>9) = 13 +79 (>9) 1 35 Addition of binary number Explanation How do we perform add and carry in binary? 0+0=0 0+1=1 1+0= 1 + 11 = 10 Addition of binary number Explanation How do we perform add and carry in binary? 1 1 1 00100111 +01001010 0 1110 001 Addition of binary number DIY How do we perform add and carry in binary? Perform 01111110 + 00111110 Addition of binary number Explanation The overflow condition 1 11 111 01101110 +11011110 1 01 001 100 Addition of binary number Explanation 1 11 111 The overflow condition 01101110 +11011110 1 01 001 100 The maximum denary of an 8-bit binary number (11111111) 8 is (2 - 1 ) = 255 The generation of a 9th bit is a clear indication that the sum has exceeded this value. This is known as an overflow error. The sum is too big to be stored using 8 bits. Addition of binary number Explanation 1 11 111 The overflow condition 01101110 01101110 = 110 +11011110 \ 11011110 = 222 1 01 001 100 110 + 222 = 322 322 > 255 (overflow) The sum is too big to be stored in a 8 bit binary. Lesson Objectives Chapter 1.4: Binary Last lesson on the binary system Shifting BINARY SHIFTING TWO COMPLEMENTS Represent Multiplication negative and division of number in binary numbers binary BINARY SHIFTING Binary shift is a process that a CPU uses to perform multiplication and division. BINARY SHIFTING - MULTIPLICATION To multiply a binary number, a CPU shifts the number to the left, filling any remaining spaces with zeros. BINARY SHIFTING - MULTIPLICATION Examples: 111 (Binary) 64 32 16 8 4 2 1 0 0 0 0 1 1 1 Examples: 1110 (Binary) 64 32 16 8 4 2 1 0 0 0 1 1 1 0 Examples: 11100 (Binary) 64 32 16 8 4 2 1 0 0 1 1 1 0 0 BINARY SHIFTING - MULTIPLICATION Examples: 111 (Binary) 64 32 16 8 4 2 1 0 0 0 0 1 1 1 Multiply by 2, shift 1 place to the left 1110 Multiply by 4, shift 2 place to the left 11100 Multiply by 8, shift 3 place to the left 111000 Multiply by 2^n, shift n place to the left BINARY SHIFTING - DIVISION For a CPU to multiply a binary number, the number needs to be shifted to the right. BINARY SHIFTING - DIVISION Examples: 101100 (Binary) 32 16 8 4 2 1 1 0 1 1 0 0 Examples: 10110 (Binary) 32 16 8 4 2 1 0 1 0 1 1 0 Examples: 1011 (Binary) 32 16 8 4 2 1 0 0 1 0 1 1 BINARY SHIFTING - DIVISION Examples: 101100 (Binary) 32 16 8 4 2 1 1 0 1 1 0 0 Divide by 2, shift 1 place to the right 10110 Divide by 4, shift 2 place to the right 1011 Divide by 8, shift 3 place to the right 101 Divide by 2^n, shift n place to the right BINARY SHIFTING WITH 8-BIT BINARY NUMBERS Registers within a CPU typically have an 8-bit limit on the data they can store at once. During the multiplication shifting process, bits can be lost from one end of the register while zeros are added to the opposite end. This phenomenon is referred to as losing the most significant bit. BINARY SHIFTING WITH 8-BIT BINARY NUMBERS Examples: 10110101 (181 in denary) 128 64 32 16 8 4 2 1 1 0 1 1 0 1 0 1 10110101 -> 01101010 106 in denary The bit lost is called the most significant bit, and when it is shifted beyond the furthest-column the binary data that is stored loses precision due to overflow. BINARY SHIFTING WITH 8-BIT BINARY NUMBERS The same process can happen when dividing an 8-bit binary number. Example: 10111101 (189 in denary) 128 64 32 16 8 4 2 1 1 0 1 1 1 1 0 1 Divide this number by 32 (move 5 places to the right) 128 64 32 16 8 4 2 1 0 0 0 0 0 1 0 1 The division shift produces the 11101 Least binary number 101 = 5, not Significant 5.9 that arithmetic suggests. bit Two’s Complement (Binary Numbers) - Allows the possibility of representing negative numbers in binary - left -most bit (LSB) is changed to a negative value - One minor change to binary headings - Left-most bit always determines the sign of the binary number -128 64 32 16 8 4 2 1 Positive Binary Number - Two’s Complement Format - Left-most bit determines the sign - 0 value indicates a positive number -128 64 32 16 8 4 2 1 0 0 1 0 1 1 0 0 Negative Binary Number - Two’s Complement Format - Left-most bit determines the sign - 1 value indicates a positive number -128 64 32 16 8 4 2 1 1 0 0 0 0 0 0 1 Converting Negative Denary Numbers into Binary using Two’s Complement Format Convert -67 into binary format -128 64 32 16 8 4 2 1 1 0 1 1 1 1 0 1 Method 1 - put 1s in their correct place Converting Negative Denary Numbers into Binary using Two’s Complement Format Convert -67 into binary format Method 2 Write the number as a positive binary value 01000011 (67) Invert each binary value, swap 1s and 0s 10111100 Add 1 1 Gives us the negative binary number 10111101

Use Quizgecko on...
Browser
Browser