Number system_lecnsjxnxnxnxnxnxnxnnxnxnjdjdn

MarlboroRed2 17 views 50 slides Jun 27, 2024
Slide 1
Slide 1 of 50
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47
Slide 48
48
Slide 49
49
Slide 50
50

About This Presentation

Xnxjjxnxjxjxjxjcjcjfjcn


Slide Content

Number System Prepared by: Risala Tasin Khan PROFESSOR IIT

2 Base-N Number System Base N N Digits: 0, 1, 2, 3, 4, 5, …, N-1 Example: 1045 N Positional Number System Digit d o is the least significant digit (LSD). Digit d n -1 is the most significant digit (MSD).

3 Decimal Number System Base 10 Ten Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Example: 1045 10 Positional Number System Digit d is the least significant digit (LSD). Digit d n -1 is the most significant digit (MSD).

4 Binary Number System Base 2 Two Digits: 0, 1 Example: 1010110 2 Positional Number System B inary Dig its are called Bits Bit b o is the least significant bit (LSB). Bit b n-1 is the most significant bit (MSB).

5 Hexadecimal Number System Base 16 Sixteen Digits: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F Example: EF56 16 Positional Number System 0000 0001 1 0010 2 0011 3 0100 4 0101 5 0110 6 0111 7 1000 8 1001 9 1010 A 1011 B 1100 C 1101 D 1110 E 1111 F

6 Definitions nybble = 4 bits byte = 8 bits (short) word = 2 bytes = 16 bits (double) word = 4 bytes = 32 bits (long) word = 8 bytes = 64 bits 1K (kilo or “kibi”) = 1,024 1M (mega or “mebi”) = (1K)*(1K) = 1,048,576 1G (giga or “gibi”) = (1K)*(1M) = 1,073,741,824

Quantities/Counting (1 of 3) Decimal Binary Octal Hexa- decimal 1 1 1 1 2 10 2 2 3 11 3 3 4 100 4 4 5 101 5 5 6 110 6 6 7 111 7 7

Quantities/Counting (2 of 3) Decimal Binary Octal Hexa- decimal 8 1000 10 8 9 1001 11 9 10 1010 12 A 11 1011 13 B 12 1100 14 C 13 1101 15 D 14 1110 16 E 15 1111 17 F

Conversion Among Bases The possibilities: Hexadecimal Decimal Octal Binary

Binary to Decimal Hexadecimal Decimal Octal Binary

Binary to Decimal Technique Multiply each bit by 2 n , where n is the “weight” of the bit The weight is the position of the bit, starting from 0 on the right Add the results

Example 101011 2 => 1 x 2 = 1 1 x 2 1 = 2 0 x 2 2 = 0 1 x 2 3 = 8 0 x 2 4 = 0 1 x 2 5 = 32 43 10 Bit “0”

Fractions Binary to decimal pp. 46-50 10.1011 => 1 x 2 -4 = 0.0625 1 x 2 -3 = 0.125 0 x 2 -2 = 0.0 1 x 2 -1 = 0.5 0 x 2 = 0.0 1 x 2 1 = 2.0 2.6875

Decimal to Binary Hexadecimal Decimal Octal Binary

Decimal to Binary Technique Divide by two, keep track of the remainder First remainder is bit 0 (LSB, least-significant bit) Second remainder is bit 1 Etc.

Example 125 10 = ? 2 2 125 62 1 2 31 0 2 15 1 2 7 1 2 3 1 2 1 1 2 0 1 125 10 = 1111101 2

Fractions Decimal to binary p. 50 3.14579 .14579 x 2 0.29158 x 2 0.58316 x 2 1.16632 x 2 0.33264 x 2 0.66528 x 2 1.33056 etc. 11.001001...

Octal to Binary Hexadecimal Decimal Octal Binary

Octal to Binary Technique Convert each octal digit to a 3-bit equivalent binary representation

Example 705 8 = ? 2 7 0 5 111 000 101 705 8 = 111000101 2

Binary to Octal Hexadecimal Decimal Octal Binary

Binary to Octal Technique Group bits in threes, starting on right Convert to octal digits

Example 1011010111 2 = ? 8 1 011 010 111 1 3 2 7 1011010111 2 = 1327 8

Hexadecimal to Binary Hexadecimal Decimal Octal Binary

Hexadecimal to Binary Technique Convert each hexadecimal digit to a 4-bit equivalent binary representation

Example 10AF 16 = ? 2 1 0 A F 0001 0000 1010 1111 10AF 16 = 0001000010101111 2

Binary to Hexadecimal Hexadecimal Decimal Octal Binary

Binary to Hexadecimal Technique Group bits in fours, starting on right Convert to hexadecimal digits

Example 1010111011 2 = ? 16 10 1011 1011 B B 1010111011 2 = 2BB 16

Decimal to Octal Hexadecimal Decimal Octal Binary

Decimal to Octal Technique Divide by 8 Keep track of the remainder

Example 1234 10 = ? 8 8 1234 154 2 8 19 2 8 2 3 8 0 2 1234 10 = 2322 8

Decimal to Hexadecimal Hexadecimal Decimal Octal Binary

Decimal to Hexadecimal Technique Divide by 16 Keep track of the remainder

Example 1234 10 = ? 16 1234 10 = 4D2 16 16 1234 77 2 16 4 13 = D 16 0 4

Hexadecimal to Octal Hexadecimal Decimal Octal Binary

Hexadecimal to Octal Technique Use binary as an intermediary

Example 1F0C 16 = ? 8 1 F 0 C 0001 1111 0000 1100 1 7 4 1 4 1F0C 16 = 17414 8

Binary Addition Two 1-bit values pp. 36-38 A B A + B 1 1 1 1 1 1 10 “two”

Binary Addition Two n -bit values Add individual bits Propagate carries E.g., 10101 21 + 11001 + 25 101110 46 1 1

Multiplication Binary, two 1-bit values A B A  B 1 1 1 1 1

Multiplication Binary, two n -bit values As with decimal values E.g., 1110 x 1011 1110 1110 0000 1110 10011010

43 Complements 1’s complement To calculate the 1’s complement of a binary number just “flip” each bit of the original binary number. E.g. 0  1 , 1  01010100100  10101011011

44 Complements 2’s complement To calculate the 2’s complement just calculate the 1’s complement, then add 1. 01010100100  10101011011 + 1= 10101011100

45 Complements Note the 2’s complement of the 2’s complement is just the original number N EX: let N = 01010100100 2’s comp of N = M = 10101011100 2’s comp of M = 01010100100 = N

46 Arithmetic Subtraction Borrow Method This is the technique you learned in grade school For binary numbers, we have 0 - 0 = 0 1 - 0 = 1 1 - 1 = 0 0 - 1 = 1 with a “borrow” 1

47 Binary Subtraction Note: A – (+B) = A + (-B) A – (-B) = A + (-(-B))= A + (+B) In other words, we can “subtract” B from A by “adding” –B to A. However, -B is just the 2’s complement of B, so to perform subtraction, we 1. Calculate the 2’s complement of B 2. Add A + (-B)

48 Binary Subtraction - Example Let n=4, A=0100 2 (4 10 ), and B=0010 2 (2 10 ) Let’s find A+B, A-B and B-A 0 1 0 0 + 0 0 1 0  (4) 10  (2) 10 0 11 0 6 A+B

49 Binary Subtraction - Example 0 1 0 0 - 0 0 1 0  (4) 10  (2) 10 10 0 1 0 2 A-B 0 1 0 0 + 1 1 1 0  (4) 10  (-2) 10 A+ (-B) “Throw this bit” away since n=4

50 Binary Subtraction - Example 0 0 1 0 - 0 1 0 0  (2) 10  (4) 10 1 1 1 0 -2 B-A 0 0 1 0 + 1 1 0 0  (2) 10  (-4) 10 B + (-A) 1 1 1 0 2 = - 0 0 1 0 2 = -2 10