Presentation is loading. Please wait.

Presentation is loading. Please wait.

Numbering Systems. CSCE 1062 Outline What is a Numbering System Review of decimal numbering system Binary representation range Hexadecimal numbering system.

Similar presentations


Presentation on theme: "Numbering Systems. CSCE 1062 Outline What is a Numbering System Review of decimal numbering system Binary representation range Hexadecimal numbering system."— Presentation transcript:

1 Numbering Systems

2 CSCE 1062 Outline What is a Numbering System Review of decimal numbering system Binary representation range Hexadecimal numbering system Converting decimal to binary

3 CSCE 1063 What is a Numbering System Can you count? What do you use to count if you are not allowed to use a calculator? What are the unique digits that you use? How many are they? Humans use a decimal (base 10) numbering system. Do you think the computer could count? What are the unique digits that a computer use? Computers use a binary (base 2) numbering system.

4 CSCE 1064 Decimal (base 10) Octal (base 8) Binary (base 2) Hexadecimal (base 16) 00 00 11 11 22 102 33 113 44 1004 55 1015 66 1106 77 1117 81010008 91110019 10121010A 11131011B 12141100C 13151101D 14161110E 15171111F 16201000010

5 CSCE 1065 Review of Decimal Numbering System Most of us are so familiar with the decimal numbering system, that we normally do not think about the issues inherent in the representation. The decimal representation is a positional numbering system. The decimal representation of any number specifies the value as a sum of individual digits times powers of ten (which is the base/radix of the decimal system). The decimal number 4321 10 is actually: 1 x 10 0 = 1 plus 2 x 10 1 = 20 plus 3 x 10 2 = 300 plus 4 x 10 3 = 4000 4321

6 CSCE 1066 Review of Decimal Numbering System (cont’d) The positions are usually (informally) named according to the numbers that they represent: thousands, hundreds, tens and ones (units). We can also name the positions after the corresponding power of 10 that each represents: position 3 (thousands), position 2 (hundreds), position 1 (tens), and position 0 (units). In mathematics and computer science positions start from 0 rather than 1. The powers increase from right to left. The number 102 10 is actually: 2 x 10 0 = 2 plus 0 x 10 1 = 0 plus 1 x 10 2 = 100 102

7 CSCE 1067 What is binary 1011 2 in decimal? 1 x 2 0 = 1 plus 1 x 2 1 = 2 plus 0 x 2 2 = 0 plus 1 x 2 3 = 8 11 10 What is octal 203 8 in decimal? 3 x 8 0 = 3 plus 0 x 8 1 = 0 plus 2 x 8 2 = 128 131 10 Exercises

8 CSCE 1068 Hexadecimal Numbering System The binary numbering system is very cumbersome in use, as it requires so many digits to represent even the relatively small values. Hexadecimal (or hex) numbering system is of particular importance, as it overcomes the above problem, by providing excellent abbreviation/concise representation. A binary number can be easily converted to hexadecimal by grouping the binary digits into blocks of four digits, to make a single hexadecimal digit, each representing a power of 16. The hexadecimal number 12 16 is: 1 x 16 1 plus 2 x 16 0 = 1 x 2 4 plus 2 x 2 0 = 1 x 2 4 plus 1 x 2 1 = 00010010 2 The binary number 101001010011 2 is composed of 3 groups of 4 binary digits: 1010 0101 0011 A 5 3 A53 16 It could be seen how conversion is straight forward.

9 CSCE 1069 What is binary 01101110 2 in decimal? 0 x 2 0 = 0 plus 1 x 2 1 = 2 plus 1 x 2 2 = 4 plus 1 x 2 3 = 8 plus 0 x 2 4 = 0 plus 1 x 2 5 = 32 plus 1 x 2 6 = 64 plus 0 x 2 7 = 0 plus 110 10 What is it in octal? 156 8 What is it in hexadecimal? 6E 16 More Exercises

10 CSCE 10610 Binary Representation Range With a single bit you can represent two distinct numbers (0 and 1). By grouping bits together, you can represent more than two unique patterns/values. With two bits you can represent four distinct patterns/values 00, 01, 10 and 11. Therefore with m bits you can represent 2 m distinct patterns/values. The distinct values that could be represented in m bits are 0, 1, 2, …, 2 m - 1. (0 <= i <= 2 m - 1 or 0 <= i < 2 m ) 16 bits (m=16) allow for representing 2 16 (65,536) different patterns/values, ranging from 0 … 65,535.

11 CSCE 10611 Converting Decimal to Binary I Since humans use decimal numbers and computers use binary, it is also useful to know how to convert decimal numbers into binary numbers. One method of converting a decimal number to a binary one involves repeatedly dividing the decimal number by 2. Then the remainders are written from right to left in the order they are generated. Converting the decimal number 29 10 to binary: 29/2 =14 rem 1 14/2 = 7 rem 0 7/2 = 3 rem 1 3/2 = 1 rem 1 1/2 = 0 rem 1 Ans:11101 2  00011101 2 (in 8 bits)

12 CSCE 10612 Exercise Convert the decimal number 110 10 to binary: 110/2 = 55 rem 0 55/2 = 27 rem 1 27/2 = 13 rem 1 13/2 = 6 rem 1 6/2 = 3 rem 0 3/2 = 1 rem 1 1/2 = 0 rem 1 Ans:1101110 2

13 CSCE 10613 Converting Decimal to Binary II Another method for converting a decimal number to a binary one involves finding those powers of two which, when added together, produce the decimal result. You should work from the largest power of two that fits in the number down to two to power 0. Convert the decimal number 29 10 to binary: 128 64 32 16 8 4 2 1 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 0 0 0 1 1 1 0 1 29 - 16 = 13 – 8 = 5 – 4 = 1 – 1 = 0 Convert the decimal number 110 10 to binary: 128 64 32 16 8 4 2 1 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 0 1 1 0 1 1 1 0 110 – 64 = 46 – 32 = 14 – 8 = 6 – 4 = 2 – 2 = 0

14 CSCE 10614 Next lecture we will continue Computer Representation of Information


Download ppt "Numbering Systems. CSCE 1062 Outline What is a Numbering System Review of decimal numbering system Binary representation range Hexadecimal numbering system."

Similar presentations


Ads by Google