Numbering Systems
CSCE 1062 Outline What is a Numbering System Review of decimal numbering system Binary representation range Hexadecimal numbering system Converting decimal to binary
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.
CSCE 1064 Decimal (base 10) Octal (base 8) Binary (base 2) Hexadecimal (base 16) A B C D E F
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 is actually: 1 x 10 0 = 1 plus 2 x 10 1 = 20 plus 3 x 10 2 = 300 plus 4 x 10 3 =
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 is actually: 2 x 10 0 = 2 plus 0 x 10 1 = 0 plus 1 x 10 2 =
CSCE 1067 What is binary in decimal? 1 x 2 0 = 1 plus 1 x 2 1 = 2 plus 0 x 2 2 = 0 plus 1 x 2 3 = What is octal in decimal? 3 x 8 0 = 3 plus 0 x 8 1 = 0 plus 2 x 8 2 = Exercises
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 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 = The binary number is composed of 3 groups of 4 binary digits: A 5 3 A53 16 It could be seen how conversion is straight forward.
CSCE 1069 What is binary 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 What is it in octal? What is it in hexadecimal? 6E 16 More Exercises
CSCE 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.
CSCE 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 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: (in 8 bits)
CSCE Exercise Convert the decimal number 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:
CSCE 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 to binary: = 13 – 8 = 5 – 4 = 1 – 1 = 0 Convert the decimal number to binary: – 64 = 46 – 32 = 14 – 8 = 6 – 4 = 2 – 2 = 0
CSCE Next lecture we will continue Computer Representation of Information