Presentation is loading. Please wait.

Presentation is loading. Please wait.

Dale & Lewis Chapter 2 Binary Numbers and Number Systems.

Similar presentations


Presentation on theme: "Dale & Lewis Chapter 2 Binary Numbers and Number Systems."— Presentation transcript:

1 Dale & Lewis Chapter 2 Binary Numbers and Number Systems

2 Number categories Definition of −Number  Unit of a mathematical system subject to arithmetic −Natural numbers  0, 1, 2, 3, 4… −Negative numbers  Number less then 0, i.e. -1, -2, -3, -4… −Integers  …-4, -3, -2, -1, 0, 1, 2, 3, 4… −Rational numbers  Fraction of integers, except division by 0, i.e. ¼, ½, -7/13…

3 The idea of a positional number system 4357 four thousand, three hundred and fifty seven four units of a thousand ( 4 x 1000) 4000 three units of a hundred ( 3 x 100) 300 five units of ten ( 5 x 10) 50 seven units of one ( 7 x 1) 7 4 x 10 3 + 3 x 10 2 + 5 x 10 1 + 7 x 10 0 5743 same digits, different positions, different number The position of each digit determines that digit’s contribution to the number.

4 The idea of a positional number system base: b any integer > 1 digits: 0, 1,..., b−1 number: d n-1 d n-2 …d 2 d 1 d 0 its definition d n-1 x b n-1 + d n-2 x b n-2 + … + d 2 x b 2 + d 1 x b 1 + d 0 x b 0 Examples: BaseDigits 20, 1 50, 1, 2, 3, 4 80, 1, 2, 3, 4, 5, 6, 7 100, 1, 2, 3, 4, 5, 6, 7, 8, 9 160, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F

5 Binary, Octal and Hexadecimal Comparison of first natural numbers in four different bases etc...

6 …So what base was used in the data in the Matrix movies?

7 Arithmetic in other bases All the familiar rules of pencil-and-paper decimal arithmetic carry over to any other base Addition 46 101110 + 27 + 11011 Subtraction 5037 - 95 57 111001 - 6 - 110 Decimal Grid Binary Grid

8 Octal Grid Hexadecimal Grid

9 Examples of arithmetic In Octal: 375476312 +6317 + 4634 In Hexadecimal: 3B6F89FCD +5743 + 9FD In Decimal: 123 + 45 +3682 + 12 + 654

10 Conversion between Decimal and Binary Binary to Decimal −Use the definition of a number in a positional number system with base 2 −Evaluate the definition formula using decimal arithmetic Example 101011 = 1 x 2 5 + 0 x 2 4 + 1 x 2 3 + 0 x 2 2 + 1 x 2 1 + 1 x 2 0 = 43 (decimal)

11 Conversion between Decimal and Binary Decimal to Binary −Repeatedly divide by 2 −Quotient Carries −Remainder is the next digit −Binary number is developed right to left Example (Quotient) (Remainder) (Binary) 173 ÷ 286 1 1 86 ÷ 2 43 0 01 43 ÷ 2 21 1 101 21 ÷ 2 10 1 1101 10 ÷ 2 5 0 01101 5 ÷ 2 2 1 101101 2 ÷ 2 1 0 0101101 1 ÷ 2 0 1 10101101

12 Generalization: Conversion between Decimal and base b Base b to Decimal −Use the definition of a number in a positional number system with base b −Evaluate the definition formula using decimal arithmetic Decimal to base b −Repeatedly divide by b −Quotient carries −Remainder is the next digit −Base b number is developed right to left

13 Conversion between Binary and Octal/Hexadecimal Binary to Octal −Group bits into threes, right to left −Convert each group into an octal digit Example 1011010111 = 001 011 010 111 = 1327 (octal) Binary to Hexadecimal −Group bits into fours, right to left −Convert each group into a hexadecimal digit Example 1011001011 = 0010 1100 1011 = 2CB (hexadecimal)

14 Conversion between Binary and Octal/Hexadecimal Octal to Binary −Convert each digit to a three-bit binary representation Example 705 = 111 000 101 = 111000101 (binary) Hexadecimal to Binary −Convert each digit to a four-bit binary representation Example 10AF = 0001 0000 1010 1111 = 0001000010101111 (binary) Conversion tables can be reconstructed in the margins of a test paper when needed

15 What about converting between Octal and Hexadecimal? Hexadecimal is not base 8, so grouping won’t work as in binary  octal or binary  hexadecimal Octal to Hexadecimal −Convert octal to binary and then binary to hexadecimal Hexadecimal to Octal −Convert hexadecimal to binary and then to octal

16

17 DecimalBinaryOctalHexadecimal 0 0 0 0 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 8 100010 8 9 100111 9 10 101012 A 11 101113 B 12 110014 C 13 110115 D 14 111016 E 15 111117 F 16100002010 17100012111 18100102212 19100112313 20101002414 21101012515 22101102616 23101112717

18 0123456789 000010203040506070809 101020304050607080910 202030405060708091011 303040506070809101112 404050607080910111213 505060708091011121314 606070809101112131415 707080910111213141516 808091011121314151617 909101112131415161718 01 00001 1 10

19 01234567 00001020304050607 10102030405060710 20203040506071011 30304050607101112 40405060710111213 50506071011121314 60607101112131415 70710111213141516

20 0123456789ABCDEF 0000102030405060708090A0B0C0D0E0F 10102030405060708090A0B0C0D0E0F10 202030405060708090A0B0C0D0E0F1011 3030405060708090A0B0C0D0E0F101112 40405060708090A0B0C0D0E0F10111213 505060708090A0B0C0D0E0F1011121314 6060708090A0B0C0D0E0F101112131415 70708090A0B0C0D0E0F10111213141516 808090A0B0C0D0E0F1011121314151617 9090A0B0C0D0E0F101112131415161718 A0A0B0C0D0E0F10111213141516171819 B0B0C0D0E0F101112131415161718191A C0C0D0E0F101112131415161718191A1B D0D0E0F101112131415161718191A1B1C E0E0F101112131415161718191A1B1C1D F0F101112131415161718191A1B1C1D1E


Download ppt "Dale & Lewis Chapter 2 Binary Numbers and Number Systems."

Similar presentations


Ads by Google