Download presentation
Presentation is loading. Please wait.
Published byMaria Palmer Modified over 9 years ago
1
Assoc. Prof. Dr. Ahmet Turan ÖZCERİT
2
The base of numbers Conversion between number bases Arithmetic operations on different bases You will learn: 2
3
He/She can define the term of number bases 3 Computers use a number base other than base-10, namely binary Each data used and stored in computer represented in binary numbers Binary numbers are not easy to do arithmetic operations, so we use hex and octal numbers for the sake of simplicity All characters, images, audio and video samples are also presented in binary numbers Computers use a number base other than base-10, namely binary Each data used and stored in computer represented in binary numbers Binary numbers are not easy to do arithmetic operations, so we use hex and octal numbers for the sake of simplicity All characters, images, audio and video samples are also presented in binary numbers
4
He/She can define the term of number bases 4 N: Digit value d: Number digit R: Number radix(base) N=d n R n + d n-1 R n-1 + …+ d 2 R 2 + d 1 R 1 +d 0 R 0 (for integers) N=d n R n +d n-1 R n-1 +…+d 1 R 1 +d 0 R 0, d 1 R -1 + d 2 R -2 +…+ d n R -n (for real numbers) The number of digits in the R-based number system is R, the largest digit is R-1, and the least digit is 0. The largest number for n-digit is R n -1 and the number of different value for n-digit is R n N: Digit value d: Number digit R: Number radix(base) N=d n R n + d n-1 R n-1 + …+ d 2 R 2 + d 1 R 1 +d 0 R 0 (for integers) N=d n R n +d n-1 R n-1 +…+d 1 R 1 +d 0 R 0, d 1 R -1 + d 2 R -2 +…+ d n R -n (for real numbers) The number of digits in the R-based number system is R, the largest digit is R-1, and the least digit is 0. The largest number for n-digit is R n -1 and the number of different value for n-digit is R n
5
He/She can make operation on binary numbers 5 The largest digit in binary system R-1 => 2-1 => 1 The least digit in binary system is 0 Each radix in binary number systems is called BIT (BInary DigiT). The most significant bit (MSB) The binary number general form: B= d n 2 n + d n-1 2 n-1 + ……. + d 2 2 2 + d 1 2 1 + d 0 2 0, d 1 2 -1 +d 2 2 -2 +d n 2 -n The largest digit in binary system R-1 => 2-1 => 1 The least digit in binary system is 0 Each radix in binary number systems is called BIT (BInary DigiT). The most significant bit (MSB) The binary number general form: B= d n 2 n + d n-1 2 n-1 + ……. + d 2 2 2 + d 1 2 1 + d 0 2 0, d 1 2 -1 +d 2 2 -2 +d n 2 -n Binary SystemDecimal System 000 011 102 113
6
He/She can make operation on binary numbers 6 What is binary value of following binary number: 1 0110 1101 B= 1*2 8 +0*2 7 +1*2 6 + 1*2 5 + 0*2 4 + 1*2 3 + 1*2 2 + 0*2 1 + 1*2 0 B= 256 + 0 + 64 + 32 + 0 + 8 + 4 + 0 + 1 B= 365 10 What is binary value of following binary number: 1 0110 1101, 1101 B= 1*2 8 +0*2 7 +1*2 6 +1*2 5 +0*2 4 +1*2 3 +1*2 2 +0*2 1 +1*2 0, 1*2 -1 +1*2 -2+ 0*2 - 3+ 1*2 -4 B= 256 + 0 + 64 + 32 + 0 + 8 + 4 + 0 + 1 + 0.5 +0.25 + 0+ 0.0625 B= 365,8125 10 What is binary value of following binary number: 1 0110 1101 B= 1*2 8 +0*2 7 +1*2 6 + 1*2 5 + 0*2 4 + 1*2 3 + 1*2 2 + 0*2 1 + 1*2 0 B= 256 + 0 + 64 + 32 + 0 + 8 + 4 + 0 + 1 B= 365 10 What is binary value of following binary number: 1 0110 1101, 1101 B= 1*2 8 +0*2 7 +1*2 6 +1*2 5 +0*2 4 +1*2 3 +1*2 2 +0*2 1 +1*2 0, 1*2 -1 +1*2 -2+ 0*2 - 3+ 1*2 -4 B= 256 + 0 + 64 + 32 + 0 + 8 + 4 + 0 + 1 + 0.5 +0.25 + 0+ 0.0625 B= 365,8125 10
7
He/She can make operation on octal numbers 7 Octal numbers are used to present binary numbers with 3-digit format The digits used in Octal Systems: 0, 1, 2, 3, 4, 5, 6, 7 O= d n 8 n + d n-1 8 n-1 + ……. + d 2 8 2 + d 1 8 1 + d 0 8 0, d 1 8 -1 +d 2 8 -2 +d n 8 -n Octal numbers are used to present binary numbers with 3-digit format The digits used in Octal Systems: 0, 1, 2, 3, 4, 5, 6, 7 O= d n 8 n + d n-1 8 n-1 + ……. + d 2 8 2 + d 1 8 1 + d 0 8 0, d 1 8 -1 +d 2 8 -2 +d n 8 -n BinaryOctal 0000 0011 0102 0113 1004 1015 1106 1117
8
He/She can make operation on hex numbers 8 Hex numbers are used to present binary numbers with 4-digit format The digits used in Octal Systems: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F O= d n 16 n + d n-1 16 n-1 + ……. + d 2 16 2 + d 1 16 1 + d 0 16 0, d 1 16 -1 +d 2 16 -2 +d n 16 -n Hex numbers are used to present binary numbers with 4-digit format The digits used in Octal Systems: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F O= d n 16 n + d n-1 16 n-1 + ……. + d 2 16 2 + d 1 16 1 + d 0 16 0, d 1 16 -1 +d 2 16 -2 +d n 16 -n BinaryHex 00000 00011 00102 00113 01004 01015 01106 01117 BinaryHex 10008 10019 1010A 1011B 1100C 1101D 1110E 1111F
9
He/She can convert number bases each other 9 The steps of converting of 117,86 10 decimal number into a binary number First, the integer part of the number is resolved then real part The steps of converting of 117,86 10 decimal number into a binary number First, the integer part of the number is resolved then real part DivisionRemainderResult 117/2 =581B 0 =1 58/2 = 29 0B 1 =0 29/2 =141B 2 =1 14/2 =70B 3 =0 7/2 =31B 4 =1 3/2 =1 1B 5 =1 1/2 =0 1B 6 =1 MultiplyIntegerResult 0.86*2=1.72 1b 1 =1 0.72*2=1.44 1b 2 =1 0.44*2=0.88 0b 3 =0 0.88*2=1.76 1b 4 =1 0.76*2=1.52 1b 5 =1 0.52*2=1.04 1b 6 =1 0.04*2=0.08 0b 7 =0 (117,86) 10 = (1110101,1101110….) 2
10
He/She can convert number bases each other 10 Convert a real decimal number (0,513) 10 into an octal number OperationMultiplyIntegerResult 0.513*84.1044o 0 =1 0.104*80.8320o 1 =0 0.832*86.6566o 2 =6 0.656*85.2485o 3 =5 0.248*81.9841o 4 =1 (0,513) 10 ≅ (0,40651) 8
11
He/She can convert number bases each other 11 Convert a decimal number (214) 10 into a hex number OperationDivisionRemainderResult 214/16136O 0 =6 13/16013O 1 =D (214) 10 = (D6) 16 Convert a decimal number (423) 10 into a hex number OperationDivisionRemainderResult 423/16267O 0 =7 26/16110O 1 =A 1 1O 2 =1 (423) 10 = (1A7) 16
12
He/She can convert number bases each other 12 Convert a binary number (100.01) 2 into a decimal number 100.01= 1*2 2 + 0*2 1 + 0*2 0, 0*2 -1 + 1*2 -2 = 1*4 + 0 + 0, 0 + 1* ¼ = 4 + 0 +0, 0+ 0.25 = (4,25) 10 Convert a binary number (100.01) 2 into a decimal number 100.01= 1*2 2 + 0*2 1 + 0*2 0, 0*2 -1 + 1*2 -2 = 1*4 + 0 + 0, 0 + 1* ¼ = 4 + 0 +0, 0+ 0.25 = (4,25) 10
13
He/She can convert number bases each other 13 Converting a binary number (110111011.1100111) 2 into an octal number For integer part; start from just after the dot towards to the leftmost digit and combine 3-bits as a group. Fill zeros if the group is less than 3-bit 1 5 6 6. For real part; start from just after the dot towards to the rightmost digit and combine 3-bits as a group. Fill zeros if the group is less than 3-bit.6 3 4 Converting a binary number (110111011.1100111) 2 into an octal number For integer part; start from just after the dot towards to the leftmost digit and combine 3-bits as a group. Fill zeros if the group is less than 3-bit 1 5 6 6. For real part; start from just after the dot towards to the rightmost digit and combine 3-bits as a group. Fill zeros if the group is less than 3-bit.6 3 4 1101110110.. 1100111
14
He/She can convert number bases each other 14 Converting a binary number (110111011.1100111) 2 into a hex number For integer part; start from just after the dot towards to the leftmost digit and combine 4-bit as a group. Fill zeros if the group is less than 4-bit 3 7 6. For real part; start from just after the dot towards to the rightmost digit and combine 4-bit as a group. Fill zeros if the group is less than 4-bit.C E Converting a binary number (110111011.1100111) 2 into a hex number For integer part; start from just after the dot towards to the leftmost digit and combine 4-bit as a group. Fill zeros if the group is less than 4-bit 3 7 6. For real part; start from just after the dot towards to the rightmost digit and combine 4-bit as a group. Fill zeros if the group is less than 4-bit.C E 1101110110.. 1100111
15
He/She can convert number bases each other 15 Converting an Octal number into a binary number Convert each digit into its 3-bit binary counterpart. Example (673.124) 8 =(110 111 011. 001 010 100) 2 Converting an octal number into a decimal number Multiply each digit’s value by radix and sum all terms Example (372.2) 8 = 3x8 2 + 7x8 1 + 2x8 0 + 2x8 -1 = 3x64 + 7x8 + 2x1 +2x0.125 =(250.25) 10 Converting an Octal number into a binary number Convert each digit into its 3-bit binary counterpart. Example (673.124) 8 =(110 111 011. 001 010 100) 2 Converting an octal number into a decimal number Multiply each digit’s value by radix and sum all terms Example (372.2) 8 = 3x8 2 + 7x8 1 + 2x8 0 + 2x8 -1 = 3x64 + 7x8 + 2x1 +2x0.125 =(250.25) 10
16
He/She can convert number bases each other 16 Converting an Octal number into a hex number Step1. Convert each digit into its 3-bit binary counterpart. Step2. Compose 4-bit groups Step3. Convert 4-bit into hex counterpart Integer part group direction. Real part group direction Example (5431) 8 = ( ? ) 16 Step1. (101 100 011 001) 2 Step2. 1011 0001 1001 Step3. B 1 9 (5431) 8 = (B19) 16 Converting an Octal number into a hex number Step1. Convert each digit into its 3-bit binary counterpart. Step2. Compose 4-bit groups Step3. Convert 4-bit into hex counterpart Integer part group direction. Real part group direction Example (5431) 8 = ( ? ) 16 Step1. (101 100 011 001) 2 Step2. 1011 0001 1001 Step3. B 1 9 (5431) 8 = (B19) 16
17
He/She can convert number bases each other 17 Converting an hex number into a binary number Convert each digit into its 4-bit binary counterpart. Example (673.124) 16 =(0110 0111 0011. 0001 0010 0100) 2 Converting an hex number into a decimal number Multiply each digit’s value by radix and sum all terms Example (372) 16 = 3x16 2 + 7x16 1 + 2x16 0 = 3x256+ 7x16 + 2x1 = 768 + 112 + 1 = (881) 10 Converting an hex number into a binary number Convert each digit into its 4-bit binary counterpart. Example (673.124) 16 =(0110 0111 0011. 0001 0010 0100) 2 Converting an hex number into a decimal number Multiply each digit’s value by radix and sum all terms Example (372) 16 = 3x16 2 + 7x16 1 + 2x16 0 = 3x256+ 7x16 + 2x1 = 768 + 112 + 1 = (881) 10
18
He/She can convert number bases each other 18 Converting an Hex number into a Octal number Step1. Convert each digit into its 4-bit binary counterpart. Step2. Compose 3-bit groups Step3. Convert 3-bit into octal counterpart Integer part group direction. Real part group direction Example (E0CA) 16 = ( ? ) 8 Step1. (1110 0000 1100 1010) 2 Step2. (001 110 000 011 001 010) 2 Step3. ( 1 6 0 3 1 2) 8 (E0CA) 16 = (160312) 8 Converting an Hex number into a Octal number Step1. Convert each digit into its 4-bit binary counterpart. Step2. Compose 3-bit groups Step3. Convert 3-bit into octal counterpart Integer part group direction. Real part group direction Example (E0CA) 16 = ( ? ) 8 Step1. (1110 0000 1100 1010) 2 Step2. (001 110 000 011 001 010) 2 Step3. ( 1 6 0 3 1 2) 8 (E0CA) 16 = (160312) 8
19
He/She can do arithmetic operations on various radix 19 0+0 =0 1+0 =1 1+1 =0 Carry=1 1 1 1 0 0 1 1 0 0 0 1 1 1 0 0 1 0 0+0 =0 1+0 =1 1+1 =0 Carry=1 1 1 1 0 0 1 1 0 0 0 1 1 1 0 0 1 0 Carry
20
He/She can do arithmetic operations on various radix 20 0-0 =0 1-0 =1 1-1 =0 0-1 =1 borrow=1 1 0 0 1 1 1 1 0 0 1 0 0-0 =0 1-0 =1 1-1 =0 0-1 =1 borrow=1 1 0 0 1 1 1 1 0 0 1 0
21
He/She can do arithmetic operations on various radix 21 In digital electronics, it is easier to create adder than subtractor unit. M-N can be redefined as M+( r complement of N) N can be negated by 1’s complement but 1’s complement contain both +0 and -0. STEP-1: Convert subtraction operation into addition by using r complement STEP-2: a. If an extra carry is obtained at the end, discard it and the number is assumed as positive. b. If no carry is obtained, apply r complement to result and add 1 In digital electronics, it is easier to create adder than subtractor unit. M-N can be redefined as M+( r complement of N) N can be negated by 1’s complement but 1’s complement contain both +0 and -0. STEP-1: Convert subtraction operation into addition by using r complement STEP-2: a. If an extra carry is obtained at the end, discard it and the number is assumed as positive. b. If no carry is obtained, apply r complement to result and add 1
22
He/She can do arithmetic operations on various radix 22 Example with extra carry: N can also be negated by 2’s complement (1’s complement+1) M=1010100, N=1000100 M-N=? M-N = M+(-N) = M+ (2’s complement of N) = M+ (1’s complement+1) 2 1’s Complement of N= (0111011) 2 2s complement of N (1’s complement of N + 1) = (0111100) 2 1010100 0111100 1 0010000 MSB is discarded, the result= (0010000) 2
23
He/She can do arithmetic operations on various radix 23 Example without extra carry: M=1000100 2 (68) 10 N =1010100 2 (84) 10 M-N =? for 2’s complement 1’s complement of N= (0101011) 2’s complement of N (1’s complement of N + 1) = (0101100) 1000100 0101100 1110000 No carry (-16) 10 1s comp 0001111 0000001 -(0010000) 2 (-16) 10
24
He/She can do arithmetic operations on various radix 24 1101 13 0101 5 1101 65 0000 1101 100001 110010 101 101 1010 00101 101 0000
25
He/She can do arithmetic operations on various radix 25
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.