Presentation is loading. Please wait.

Presentation is loading. Please wait.

Positional Number Systems

Similar presentations


Presentation on theme: "Positional Number Systems"— Presentation transcript:

1 Positional Number Systems
Jim Williams HONP112 Week 1 Rev. 9/2011

2 Why Math? To understand computers, we will become familiar with a little math background. We will not get into anything very difficult We will, however, look at numbers a bit differently than we normally do.

3 Numbering Systems Numbering systems are necessary to represent quantities of things and to perform math. It is important to understand that there can be more than one way to represent the same quantity.

4 Example: the quantity “seventeen”
In Roman numerals the symbol is XVII. Using tick marks the symbol is IIII IIII IIII II. Using a decimal number, the symbol is 17 Using a binary number the symbol is (more about that later!) Can you think of any others?

5 Non-positional systems
In our previous example, notice something important. For the Roman Numerals and Tick Marks, the position / column that the digits were in did not matter. The same digit represented the same quantity, regardless of the column. We are not concerned with these systems for this course.

6 Positional systems Notice however that in the decimal and binary systems, the column that the symbol was in did matter. Positional numbering systems are only possible because of a placeholder value (the zero). This allows the concept of a “place value” where the same digit can represent a different quantity, depending on the column. These systems can be understood in terms of digits, positions, and bases.

7 Digits A single digit symbol consists of a single instance of a certain number of different values. These values always start with 0 and increment. Of course, we eventually run out of digit values when representing numbers in a single digit (try counting to twenty-five using a single digit). When we run out of “space” when using a single digit, we have to carry into the next position.

8 Positions (AKA Columns)
Let’s look at the positions in our own numbering system. 1000s 100s 10s 1s The value of the digit depends on which column, or position, it is in. You can see how the quantity 3,087 is really represented by adding the quantities represented by each symbol in the columns.

9 More on Positions * Positions are numbered from RIGHT to LEFT, starting with ZERO (we will not deal with fractional numbers) In our example: 3,087 the “7” is in position 0, the 8 is in position 1, and so on. What numeric value does the digit in position 1 have?

10 Place value of a digit In the number 3,087 , the true numeric value – commonly called the “place value” - of the digit in position 1 is 80, not 8. Why? Because position 1 is the “10s” column, we multiply the digit value (8) by x 10 = 80. Adding all the numeric values of each digit gives us our total of 3,087.

11 So what about the Base? The Base (AKA “Radix”) of a numbering system determines two important things: 1. The number of possible values that can be represented by a single digit symbol. 2. What the columns represent powers of. Remember that this is critical to determining the place value of digits, relative to their columns.

12 Why the base is important
Without knowing the base of a symbol, we have no way to know for certain the quantity that is represented by the symbol. For example, consider the symbol “702”. What quantity does this symbol represent if the columns are powers of 10? How about powers of 12?

13 The Decimal Number System
We use the decimal (Base-10) number system every day. The prefix “dec” means “ten” (example: a decade is a period of 10 years) You probably felt our last example was simple. Let’s examine it a bit further.

14 Base-10 digits and positions
Each digit can have one of only 10 possible values. {0,1,2,3,4,5,6,7,8,9} Position numbers represent powers of 10 So, the numeric value of a digit in a position can be calculated as follows n = d * (bp) d=digit value, b=base (10), and p=position number.

15 Powers Remember, a power is how many times a number is multiplied by itself. For example, 10 raised to the 3rd power (written as 103), is 10x10x10, or 1000. Exception: Any number raised to the zero power is always 1 (ex. 100 = 1, 20=1, etc.)

16 Base-10 Powers and Positions
Let’s look at the positions in our own numbering system (Base-10) once again. 1000s 100s 10s 1s This can also be understood in terms of powers of 10. o

17 Quantity represented by a Base-10 number
Using 3,087 as an example, we find the individual value of each digit, then add them together n = 3 * (103) = 3,000 n = 0 * (102) = 0 n = 8 * (101) = 80 n = 7 * (100) = 7 3, = 3,087

18 The Hexadecimal Number System
Now that we understand the way the base-10 system works, let’s try something a little different. It is possible to use bases larger than 10, which might seem strange to us. We will use the Hexadecimal (base-16) system as an example. Notation: For bases other than 10, we sometimes write the base in subscript. For clarity we will do this in some examples.

19 Hexadecimal (Base-16) Digits
Since the base is 16, this means that a single digit can have one of 16 possible values These are {0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F} The digit A represents the quantity “10”, the digit B represents the quantity “11”, and so on until we reach F, which represents the quantity “15”.

20 Hexadecimal Number Examples
7816 2D16 1F016 You must keep in mind that since the base of the hexadecimal number system is 16, the actual quantity represented by these numbers is different than we first think (ie. the first number is NOT “seventy-eight.”)

21 How do we understand Base-16 numbers?
In the following slides, we will examine an example hexadecimal number. We will also describe the numbering system rules in a similar way that we described the Base-10 rules. Using these rules, we can convert a hexadecimal number to something we understand.

22 Example Hexadecimal Number
For an example, let’s use 2E16. Since we are told it is hexadecimal, we know that the numbering system has a base of 16. Knowing this, we can evaluate the value of each digit and add them just like we did for decimal numbers.

23 Base-16 digits and positions
Each digit can have one of only 16 possible values. (0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F) Position numbers represent powers of 16 So, the numeric value of a digit in a position can be calculated as follows n = d * (bp) d=digit value, b=base (16), and p=position number.

24 Remember your Powers of 16
You already know what a power is. Here are some powers of 16. 160=1 161 = 16 162 = 16x16 = 256 Try some others yourself.

25 Base-16 Powers and Positions
Our Base-16 number example is 2E Let’s look at the digits in their positions. This time, we use powers of 16. o 2 E Which can also be seen as 16s 1s

26 Quantity Represented a single digit in Base-16
Using 2E as an example, find the numeric value (or the quantity represented) of the digit in position 0 n = d * (bp) n = E * (160) [remember that E=14] n = 14

27 Quantity Represented by a Base-16 number
Using 2E as an example, we find the individual value of each digit, then add them together n = 2 * (161) = 32 n = E * (160) = 14 32+14 = 46 (our decimal equivalent)

28 Given a base and a symbol...
As you can see we follow the same rules to determine the quantity represented by a symbol in any base. Here are the steps illustrated. To do this we need to know both the symbol, and the base. Let’s work through an example. Symbol = Base = 8

29 Step 1: Prepare your column table
Create a 2-row table for however many columns you have. The heading row will contain the column values. Notice that the column headings start with the power of zero in the rightmost column, and increment going left. The “b” is just a substitute for the base we will use.

30 Step 2: Enter your base in the column headings
82 81 80 Notice that the column headings are in powers of 8 (the given radix).

31 Step 2: Draw in your symbol digits
82 81 80 6 7 5 Our symbol 6758 is now placed in the correct columns.

32 Step 4: Determine the quantity represented by each single digit.
82 81 80 6 7 5 5 * 80 = 5 * 1 = 5 7 * 81 = 7 * 8 = 56 6 * 82 = 7 * 64 = 384

33 Step 5: Add them up. 82 81 80 6 7 5 5 * 80 = 5 * 1 = 5 7 * 81 = 7 * 8 = 56 6 * 82 = 6 * 64 = 384 = 445 The symbol 675 in Base 8 represents the quantity 445.

34 Another example: in class
Using the five steps, work out the quantity represented by the symbol 3021 in base-4.

35 Keeping it legal In our base-8 example, could we have had a digit symbol of 8? Of 9? NO. Because in base 8, we can only have 8 digit symbols, starting with zero. These would be {0,1,2,3,4,5,6,7}. If any digit represents a quantity greater than or equal to the base, it is not valid.

36 Are these legal or not? Symbol = 390 Base = 5 Symbol = 673 Base = 9
Symbol = 8AC Base = 16 Symbol = 8AC Base = 11 Symbol = Base = 10.

37 Are these legal or not? Symbol = 390 Base = 5 ILLEGAL (9)
Symbol = 673 Base = 9 Legal Symbol = 120 Base = 2 ILLEGAL (2) Symbol = 101 Base = 2 Legal Symbol = 8AC Base = 16 Legal Symbol = 8AC Base = 11 ILLEGAL (C) Symbol = Base = 10 Legal

38 The Binary Number System
Computers use the Binary (Base-2) number system. As you already know, the prefix “bi” means “two” (bi-cycle, bi-weekly, etc.) The digital electronics used by the computer are based on the binary number system.

39 Binary (Base-2) Digits A binary digit is called a Bit (short for binary digit). Bits can have a value of either 0 or 1 The 0 and 1 correspond with the electronic states of “low/high” or “off/on”. These values also have a logical value of “false/true”

40 Binary Number Examples
10012 1112 You must keep in mind that since the base of the binary number system is 2, the actual quantity represented by these numbers is different than we first think (ie. the 3rd number is NOT one-hundred-eleven)

41 How do we understand binary numbers?
In the following slides, we will examine an example binary number. We will also describe the numbering system rules in a similar way that we described the Base-10 rules. Using these rules, we can convert a binary number to something we understand.

42 Example Binary Number For an example, let’s use 1101.
Since we are told it is binary, we know that the numbering system has a base of 2. Knowing this, we can evaluate the value of each digit and add them just like we did for decimal numbers.

43 Base-2 digits and positions
Each digit can have one of only 2 possible values. (0,1) Position numbers represent powers of 2 So, the numeric value of a digit in a position can be calculated as follows n = d * (bp) d=digit value, b=base (2), and p=position number.

44 Remember your Powers of 2
You already know what a power is. Here are some powers of 2. 20=1 21 = 2 23 = 2x2x2 = 8 25 = 2x2x2x2x2 = 32 Try some others yourself.

45 Base-2 Powers and Positions
Our Binary number example is 1101 Let’s look at the digits in their positions. This time, we use powers of 2. o Which can also be seen as 8s 4s 2s 1s

46 Numeric value of a single digit in Base-2
Using 1101 as an example, find the numeric value of the digit in position 3 n = d * (bp) n = 1 * (23) n = 8

47 Numeric value of a Base-2 number
Using 1101 as an example, we find the individual value of each digit, then add them together n = 1 * (23) = 8 n = 1 * (22) = 4 n = 0 * (21) = 0 n = 1 * (20) = 1 = 13 (our decimal equivalent)

48 Notice Something We used the formula n = d * (bp) to find the numeric value of each single digit. However, in binary, d will always be either 0 or 1. Therefore, we can simplify our formula.

49 Numeric value of a single digit in Base-2, simplified.
If a zero, ignore it (it is still 0). If a 1, it is equal to the position multiplier So, our original single digit numeric value formula, n = d * (bp) , becomes simply: n = (bp) , where d=1

50 Let’s try a bigger Base-2 Number
Let’s use Positions 0,1,2,4,and 5 contain zeroes. So we ignore them. As for the rest… Position 7: n = (bp) = (27) = 128 Position 6: n = (bp) = (26) = 64 Position 3: n = (bp) = (23) = 8 = 200 (our decimal equivalent)

51 Another Example What is the numeric (decimal) value of the binary number ? 1. Place digits into the columns 2. Add the numeric values of each “1” digit , or Answer = 58

52 Adding Numbers of any Base
The general algorithm for adding any two whole numbers of any base, one digit at a time, is illustrated in the next slide. You use the same algorithm whenever you add 2 Base-10 numbers every day. You probably just don’t think about it in much detail.

53 Base-n Addition Algorithm
1. Start at the rightmost column with carry value set to zero. 2. Starting at the rightmost position, add the two quantities represented by the digits to the current carry value. 3. If the sum is greater than or equal to the base, subtract the base from the sum and set the carry to one. Place the remainder in the result digit. 4. If sum is less than the base, set the carry to zero. Place the sum in the result digit. 5. Move to the next column (to the left). Repeat from step 2 until you are out of columns to add. 6. If carry still equals one, create a new leftmost result column and place the carry in it.

54 Addition: Try it Try adding any 2 numbers of any (positive integer) base using the algorithm. Example: Two Base-5 numbers (43, 14) The sum in Base-5 representation is 112. Why?? Bonus question: What actual quantity is represented by the Base-5 number 112?

55 Some more addition Examples
Base-2: = 100 Base-2: = 111 Base-8: = 52 Base-16: = 4D Base-6: = 20 Base-10: = 52 Base-12: 1B + 2 = 21 * Use the base-n addition algorithm to verify these results! *


Download ppt "Positional Number Systems"

Similar presentations


Ads by Google