Download presentation
Presentation is loading. Please wait.
Published byJonas Ross Modified over 9 years ago
1
Numbering System Base Conversion
2
Number systems Decimal – 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Binary – 0, 1 Octal – 0, 1, 2, 3, 4, 5, 6, 7 Hexadecimal system – 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
3
Why different number systems? Binary number result in quite a long string of 0s and 1s Easier for the computer to interpret input from the user
4
Base Conversion In daily life, we use decimal (base 10) number system Computer can only read in 0 and 1 Number system being used inside a computer is binary (base 2) Octal (base 8) and hexadecimal (base 16) are used in programming for convenience
5
Base Conversion Conversion Binary number, Octal number, Hexadecimal number, and Decimal number.
6
Base Conversion BinaryOctalHexadecimalDecimal 0000000 0001111 0010222 0011333 0100444 0101555 0110666 0111777 10001088 10011199 101012A10 101113B11 110014C12 110115D13 111016E14 111117F15
7
Base Conversion For example: 62 = 111110 = 76 = 3E decimal binary octal hexadecimal 1For Decimal: 62 = 6x10 1 + 2x10 0 2 For Binary: 111110 = 1x2 5 + 1x2 4 + 1x2 3 + 1x2 2 + 1x2 1 + 0x2 0 3For Octal: 76 = 7x8 1 + 6x8 0 4For Hexadecimal: 3E = 3x16 1 + 14x16 0 Since for hexadecimal system, each digit contains number from 1 to 15, thus we use A, B, C, D, E and F to represent 10, 11, 12, 13, 14 and 15.
8
Binary and decimal system Binary to decimal X. 2 7 + X. 2 6 + X. 2 5 + X. 2 4 + X. 2 3 + X. 2 2 + X. 2 1 + X. 2 0 Decimal to binary Keep dividing the number by two and keep track of the remainders. Arrange the remainders (0 or 1) from the least significant (right) to most significant (left) digits
9
Octal and Hexadecimal system Binary to Octal (8 = 2 3 ) Every 3 binary digit equivalent to one octal digit Binary to Hexadecimal (16 = 2 4 ) Every 4 binary digit equivalent to one hexadecimal digit Octal to binary Every one octal digit equivalent to 3 binary digit Hexadecimal to binary Every one hexadecimal digit equivalent to 4 binary digits
10
Base Conversion How to convert the decimal number to other number system e.g. convert 18 10 in binary form 2 |18 ----0 2 |09 ----1 2 |04 ----0 2 |02 ----0 1 18 10 = 10010 2
11
Base Conversion e.g. convert 18 10 in octal form Since for octal form, one digit is equal to 3 digits in binary number, we can change binary number to octal number easily. e.g. 10010 = 010 010 2 2 Thus, 10010 2 = 22 8
12
Base Conversion e.g. convert 18 10 in hexadecimal form Similarly, for hexadecimal form, one digit is equal to 4 digits in binary number. e.g. 10010 = 0001 0010 1 2 Thus, 10010 2 = 12 16
13
Numbering System Addition & Subtraction
14
Decimal Addition 111 3758 + 4657 8415 What is going on? 1 1 1 (carry) 3 7 5 8 + 4 6 5 7 14 11 15 - 10 10 10 (subtract the base) 8 4 1 5
15
Binary Addition Rules. 0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 2 = 10 2 = 0 with 1 to carry 1 + 1 + 1 = 3 = 11 2 = 1 with 1 to carry
16
Binary Addition 1 1 1 1 1 1 0 1 1 1 + 0 1 1 1 0 0 2 3 2 2 - 2 2 2 2 1 0 1 0 0 1 1 Verification 55 10 + 28 10 83 10 64 32 16 8 4 2 1 1 0 1 0 0 1 1 = 64 + 16 + 2 +1 = 83 10
17
Binary Addition ex Verification 1 0 0 1 1 1 + 0 1 0 1 1 0 + ___ ___________ 128 64 32 16 8 4 2 1 =
18
Octal Addition 1 1 6 4 3 7 8 + 2 5 1 0 8 9 9 - 8 8 (subtract Base (8)) 1 1 1 4 7 8
19
Octal Addition ex 3 5 3 6 8 + 2 4 5 7 8 - (subtract Base (8))
20
Hexadecimal Addition 1 1 7 C 3 9 16 + 3 7 F 2 16 20 18 11 - 16 16 (subtract Base (16)) B 4 2 B 16
21
Hexadecimal Addition 8 A D 4 16 + 5 D 6 16 - (subtract Base (16)) 16
22
Decimal Subtraction 7 13 10 8 4 1 15 - 4 6 5 7 3 7 5 8 How it was done? ( add the base 10 when borrowing) 10 10 7 3 0 10 8 4 1 5 13 10 15 - 4 6 5 7 3 7 5 8
23
Binary Subtraction 1 2 1 0 2 0 2 2 1 0 1 0 0 1 1 - 0 1 1 1 0 0 1 1 0 1 1 1 Verification 83 10 - 28 10 55 10 64 32 16 8 4 2 1 1 1 0 1 1 1 = 32 + 16 + + 4 + 2 +1 = 55 10
24
Binary Subtraction ex Verification 1 0 0 1 1 1 - 0 1 0 1 1 0 - ___ ___________ 128 64 32 16 8 4 2 1 =
25
Octal Subtraction 8 0 0 8 1 1 1 4 7 8 8 9 - 6 4 3 7 8 2 51 0 8
26
Octal Subtraction ex 3 5 3 6 8 - 2 4 5 7 8
27
Hexadecimal Subtraction B 16 7 C 3 9 16 19 - 3 7 F 2 16 4 4 4 7 16
28
Hexadecimal Subtraction 8 A D 4 16 - 5 D 6 16 16
29
Let’s do some exercises! Octal, Hexadecimal, Binary Addition & Subtraction
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.