Presentation is loading. Please wait.

Presentation is loading. Please wait.

Numbering Systems and Arithmetic operations on Hex, binary, and octal

Similar presentations


Presentation on theme: "Numbering Systems and Arithmetic operations on Hex, binary, and octal"— Presentation transcript:

1 Numbering Systems and Arithmetic operations on Hex, binary, and octal
Chapter 0 Numbering Systems and Arithmetic operations on Hex, binary, and octal By: Bryar M. Shareef

2 Common Number Systems System Base Symbols Used by humans?
Used in computers? Decimal 10 0, 1, … 9 Yes No Binary 2 0, 1 Octal 8 0, 1, … 7 Hexa- decimal 16 0, 1, … 9, A, B, … F

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

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

5 Quantities/Counting (3 of 3)
Decimal Binary Octal Hexa- decimal 16 10000 20 10 17 10001 21 11 18 10010 22 12 19 10011 23 13 10100 24 14 10101 25 15 10110 26 10111 27 Etc.

6 Conversion Among Bases
The possibilities: Decimal Octal Binary Hexadecimal pp

7 Quick Example 2510 = = 318 = 1916 Base

8 Decimal to Decimal (just for fun)
Octal Binary Hexadecimal Next slide…

9 Weight 12510 => 5 x 100 = x 101 = x 102 = Base

10 Binary to Decimal Decimal Octal Binary Hexadecimal

11 Binary to Decimal Technique
Multiply each bit by 2n, 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

12 Example Bit “0” => 1 x 20 = x 21 = x 22 = x 23 = x 24 = x 25 = 32 4310

13 Octal to Decimal Decimal Octal Binary Hexadecimal

14 Octal to Decimal Technique
Multiply each bit by 8n, 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

15 Example 7248 => 4 x 80 = x 81 = x 82 =

16 Hexadecimal to Decimal
Octal Binary Hexadecimal

17 Hexadecimal to Decimal
Technique Multiply each bit by 16n, 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

18 Example ABC16 => C x 160 = 12 x 1 = B x 161 = 11 x 16 = A x 162 = 10 x 256 = 2560 274810

19 Decimal to Binary Decimal Octal Binary Hexadecimal

20 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.

21 Example 12510 = ?2 12510 =

22 Octal to Binary Decimal Octal Binary Hexadecimal

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

24 Example 7058 = ?2 7058 =

25 Hexadecimal to Binary Decimal Octal Binary Hexadecimal

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

27 Example 10AF16 = ?2 A F 10AF16 =

28 Decimal to Octal Decimal Octal Binary Hexadecimal

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

30 Example = ?8 8 19 2 8 2 3 8 0 2 = 23228

31 Decimal to Hexadecimal
Octal Binary Hexadecimal

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

33 Example = ?16 77 2 16 = D 0 4 = 4D216

34 Binary to Octal Decimal Octal Binary Hexadecimal

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

36 Example = ?8 = 13278

37 Binary to Hexadecimal Decimal Octal Binary Hexadecimal

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

39 Example = ?16 B B = 2BB16

40 Octal to Hexadecimal Decimal Octal Binary Hexadecimal

41 Octal to Hexadecimal Technique Use binary as an intermediary

42 Example 10768 = ?16 E 10768 = 23E16

43 Hexadecimal to Octal Decimal Octal Binary Hexadecimal

44 Hexadecimal to Octal Technique Use binary as an intermediary

45 Example 1F0C16 = ?8 1 F C 1F0C16 =

46 Exercise – Convert ... Decimal Binary Octal Hexa- decimal 33 1110101
703 1AF Don’t use a calculator! Skip answer Answer

47 Exercise – Convert … Decimal Binary Octal Hexa- decimal 33 100001 41
Answer Decimal Binary Octal Hexa- decimal 33 100001 41 21 117 165 75 451 703 1C3 431 657 1AF

48 What is the two’s complement?
A two's-complement system is a system in which negative numbers are represented by the two's complement of the absolute value

49 Example Suppose we're working with 8 bit and suppose we want to find how -28 would be expressed in two's complement notation. First we write out 28 in binary form. Then we invert the digits. 0 becomes 1, 1 becomes 0. Then we add 1. That is how one would write -28 in 8 bit binary.

50

51 Common Powers (1 of 2) Base 10 Power Preface Symbol pico p nano n
10-12 pico p 10-9 nano n 10-6 micro 10-3 milli m 103 kilo k 106 mega M 109 giga G 1012 tera T Value .001 1000

52 Common Powers (2 of 2) Base 2 What is the value of “k”, “M”, and “G”?
Preface Symbol 210 kilo k 220 mega M 230 Giga G Value 1024 What is the value of “k”, “M”, and “G”? In computing, particularly w.r.t. memory, the base-2 interpretation generally applies

53

54 Example In the lab… 1. Double click on My Computer 2. Right click on C: 3. Click on Properties / 230 =

55 Review – multiplying powers
For common bases, add powers ab  ac = ab+c 26  210 = 216 = 65,536 or… 26  210 = 64  210 = 64k

56 Binary Addition (1 of 2) Two 1-bit values A B A + B 1 10 “two”

57 Binary Addition (2 of 2) Two n-bit values Add individual bits
Propagate carries E.g., 1 1

58 Multiplication (1 of 3) Decimal (just for fun)
35 x

59 Multiplication (2 of 3) Binary, two 1-bit values A B A  B 1

60 Multiplication (3 of 3) Binary, two n-bit values
As with decimal values E.g., x

61 Fractions Decimal to decimal (just for fun)
3.14 => 4 x 10-2 = x 10-1 = x 100 =

62 Fractions Binary to decimal
=> 1 x 2-4 = x 2-3 = x 2-2 = x 2-1 = x 20 = x 21 =

63 Fractions Decimal to binary 3.14579 11.001001...
x x x x x x etc. Decimal to binary

64 Exercise – Convert ... Decimal Binary Octal Hexa- decimal 29.8
3.07 C.82 Don’t use a calculator! Skip answer Answer

65 Exercise – Convert … Decimal Binary Octal Hexa- decimal 29.8
Answer Decimal Binary Octal Hexa- decimal 29.8 35.63… 1D.CC… 5.8125 5.64 5.D 3.07 3.1C 14.404 C.82

66 Arithmetic Operations on Hex, Binary, Octal

67 Decimal Addition 111 3758 + 4657 8415 3 7 5 8 What is going on?
(carry) (subtract the base)

68 Binary Addition Rules. 0 + 0 = 0 0 + 1 = 1 1 + 0 = 1
1 + 1 = 2 = 102 = 0 with 1 to carry = 3 = 112 = 1 with 1 to carry

69 Binary Addition Verification 5510 + 2810 8310 = = 8310

70 Binary Addition ex Verification = 1 0 0 1 1 1 + 0 1 0 1 1 0 + ___
___ ___________ =

71 Octal Addition 1 1 6 4 3 78 + 2 5 1 08 9 9 - 8 8 (subtract Base (8))
9 9 (subtract Base (8))

72 Octal Addition ex (subtract Base (8))

73 Hexadecimal Addition 1 1 7 C 3 916 + 3 7 F 216 20 18 11
1 1 7 C F 216 (subtract Base (16)) B B16

74 Hexadecimal Addition 8 A D 416 D 616 (subtract Base (16)) 16

75 Decimal Subtraction How it was done? ( add the base 10 when borrowing) 10 10

76 Binary Subtraction Verification 8310 5510 = = 5510

77 Binary Subtraction ex Verification = 1 0 0 1 1 1 - 0 1 0 1 1 0 - ___
___ ___________ =

78 Octal Subtraction

79 Octal Subtraction ex

80 Hexadecimal Subtraction
B 16 7 C F

81 Hexadecimal Subtraction
16

82 Thanks


Download ppt "Numbering Systems and Arithmetic operations on Hex, binary, and octal"

Similar presentations


Ads by Google