Presentation is loading. Please wait.

Presentation is loading. Please wait.

CMSC 1041 Binary / Hex Binary and Hex The number systems of Computer Science.

Similar presentations


Presentation on theme: "CMSC 1041 Binary / Hex Binary and Hex The number systems of Computer Science."— Presentation transcript:

1 CMSC 1041 Binary / Hex Binary and Hex The number systems of Computer Science

2 CMSC 1042 Main Memory l Capacitors on/off translates to values 1/0 l requires use of Binary number system l Investigate Decimal number system first

3 CMSC 1043 The Decimal Numbering System l The decimal numbering system is a positional number system. l Example: 5 6 2 11 X 10 0 1000 100 10 1 2 X 10 1 6 X 10 2 5 X 10 3

4 CMSC 1044 What is the base ? l The decimal numbering system is also known as base 10. The values of the positions are calculated by taking 10 to some power. l Why is the base 10 for decimal numbers ? Because we use 10 digits. The digits 0 through 9.

5 CMSC 1045 What is the base ? l The binary numbering system is called binary because it uses base 2. The values of the positions are calculated by taking 2 to some power. l Why is the base 2 for binary numbers ? Because we use 2 digits. The digits 0 and 1.

6 CMSC 1046 The Binary Numbering System l The Binary Numbering System is also a positional numbering system. l Instead of using ten digits, 0 - 9, the binary system uses only two digits, the 0 and the 1. l Example of a binary number & the values of the positions. 1 0 0 0 0 0 1 2 6 2 5 2 4 2 3 2 2 2 1 2 0

7 CMSC 1047 Computing the Decimal Values of Binary Numbers 1 0 0 0 0 0 11 X 2 0 = 1 2 6 2 5 2 4 2 3 2 2 2 1 2 0 0 X 2 1 = 0 0 X 2 2 = 0 2 0 = 1 2 4 = 16 0 X 2 3 = 0 2 1 = 2 2 5 = 32 0 X 2 4 = 0 2 2 = 4 2 6 = 64 0 X 2 5 = 0 2 3 = 81 X 2 6 = 64 65

8 CMSC 1048 Converting Decimal to Binary l First make a list of the values of 2 to the powers of 0 to 8, then use the subtraction method. 2 0 = 1, 2 1 = 2, 2 2 = 4, 2 3 = 8, 2 4 = 16, 2 5 = 32, 2 6 = 64, 2 7 = 128, 2 8 = 256 l Example:4242 10 2 - 32 - 8 - 2 1 0 1 0 1 0 2 5 2 4 2 3 2 2 2 1 2 0

9 CMSC 1049 Counting in Binary l Binary 0 1 10 11 100 101 110 111 l Decimal equivalent 0 1 2 3 4 5 6 7

10 CMSC 10410 Addition of Binary Numbers l Examples: 1 0 0 10 0 0 11 1 0 0 + 0 1 1 0 + 1 0 0 1 + 0 1 0 1 1 1 1 11 0 1 0 1 0 0 0 1

11 CMSC 10411 Addition of Large Binary Numbers l Example showing larger numbers: 1 0 1 0 0 0 1 1 1 0 1 1 0 0 0 1 + 0 1 1 1 0 1 0 0 0 0 0 1 1 0 0 1 1 0 0 0 1 0 1 1 1 1 1 0 0 1 0 1 0

12 CMSC 10412 Working with large numbers 0 1 0 1 0 0 0 0 1 0 0 1 0 1 1 1 l Humans can’t work well with binary numbers. We will make errors. l Shorthand for binary that’s easier for us to work with - Hexadecimal

13 CMSC 10413 Hexadecimal Binary 0 1 0 1 0 0 0 0 1 0 0 1 0 1 1 1 Hex 5 0 9 7 Written: 5097 16

14 CMSC 10414 What is Hexadecimal really ? Binary 0 1 0 1 0 0 0 0 1 0 0 1 0 1 1 1 Hex 5 0 9 7 A number expressed in base 16. It’s easy to convert binary to hex and hex to binary because 16 is 2 4.

15 CMSC 10415 Hexadecimal l Binary is base 2, because we use two digits, 0 and 1 l Decimal is base 10, because we use ten digits, 0 through 9. l Hexadecimal is base 16. How many digits do we need to express numbers in hex ? 16 (0 through ?) l 0 1 2 3 4 5 6 7 8 9 A B C D E F

16 CMSC 10416 Counting in Hex Binary HexBinaryHex 0 0 0 0 01 0 0 0 8 0 0 0 1 11 0 0 1 9 0 0 1 0 21 0 1 0 A 0 0 1 1 31 0 1 1 B 0 1 0 0 41 1 0 0 C 0 1 0 1 51 1 0 1 D 0 1 1 0 61 1 1 0 E 0 1 1 1 71 1 1 1 F

17 CMSC 10417 Another Binary to Hex Conversion Binary 0 1 1 1 1 1 0 0 0 0 1 1 1 1 1 1 Hex 7 C 3 F 7C3F 16


Download ppt "CMSC 1041 Binary / Hex Binary and Hex The number systems of Computer Science."

Similar presentations


Ads by Google