140 likes | 170 Views
Numbering Systems. Outline. What is a Numbering System Review of decimal numbering system Binary representation range Hexadecimal numbering system Converting decimal to binary. What is a Numbering System. Can you count? What do you use to count if you are not allowed to use a calculator?
E N D
Outline • What is a Numbering System • Review of decimal numbering system • Binary representation range • Hexadecimal numbering system • Converting decimal to binary CSCE 106
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. CSCE 106
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 432110 is actually: 1 x 100 = 1 plus 2 x 101 = 20 plus 3 x 102 = 300 plus 4 x 103 = 4000 4321 CSCE 106
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 10210 is actually: 2 x 100 = 2 plus 0 x 101 = 0 plus 1 x 102 = 100 102 CSCE 106
Exercises • What is binary 10112 in decimal? 1 x 20 = 1 plus 1 x 21 = 2 plus 0 x 22 = 0 plus 1 x 23 = 8 1110 • What is octal 2038 in decimal? 3 x 80 = 3 plus 0 x 81 = 0 plus 2 x 82 = 128 13110 CSCE 106
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 1216 is: 1 x 161 plus 2 x 160 = 1 x 24 plus 2 x 20 = 1 x 24 plus 1 x 21 = 000100102 • The binary number 1010010100112 is composed of 3 groups of 4 binary digits: 1010 0101 0011 A 5 3 A5316 • It could be seen how conversion is straight forward. CSCE 106
More Exercises • What is binary 011011102 in decimal? 0 x 20 = 0 plus 1 x 21 = 2 plus 1 x 22 = 4 plus 1 x 23 = 8 plus 0 x 24 = 0 plus 1 x 25 = 32 plus 1 x 26 = 64 plus 0 x 27 = 0 plus 11010 • What is it in octal? 1568 • What is it in hexadecimal? 6E16 CSCE 106
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 2m distinct patterns/values. • The distinct values that could be represented in m bits are 0, 1, 2, …, 2m- 1. (0 <= i <=2m- 1 or 0 <= i <2m ) • 16 bits (m=16) allow for representing 216 (65,536) different patterns/values, ranging from 0 … 65,535. CSCE 106
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 2910 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: 111012 000111012 (in 8 bits) CSCE 106
Exercise • Convert the decimal number 11010 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: 11011102 CSCE 106
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 2910 to binary: 128 64 32 16 8 4 2 1 27 26 25 24 23 22 21 20 0 0 0 1 1 1 0 1 29 - 16 = 13 – 8 = 5 – 4 = 1 – 1 = 0 • Convert the decimal number 11010 to binary: 128 64 32 16 8 4 2 1 27 26 25 24 23 22 21 20 0 1 1 0 1 1 1 0 110 – 64 = 46 – 32 = 14 – 8 = 6 – 4 = 2 – 2 = 0 CSCE 106
Next lecture we will continue Computer Representation of Information CSCE 106