PowerPoint Presentation
TU856-1 & TU858-1 Computer Architecture and Technology
Module Code: CMPU 1006
NUMBER BASES
Presenter: Dr Art Sloan
Semester 1, Week 4
1
Presentation Outline
This presentation is a quick look at number bases; namely, decimal, binary, octal and hexadecimal.
It will focus on the structure of the number bases, and how that structure relates to data storage.
There are some quick and simple examples of the mathematical aspects of the number bases the use of Twos Complement to manage minus calculations in a computer, for example.
2
Presentation Content including
What is Information to a Computer?
Number Bases
Bytes
Binary
Binary Mathematics
Binary Negative Numbers
Twos Complement
3
Octal Number Representation
Octal Numbers and Bytes
Hexadecimal Number Representation
Hexadecimal Numbers and Bytes
Lecture Summary
Where to Next?
What is Information to a Computer?
A computer functions on electricity and magnetism. The magnetism is very often a product of electrical flow.
There is a great deal of light and reflection in modern hardware (lasers and fibre optics) but light is a medium generated by electrical flow.
4
What is Information to a Computer? (2)
Electricity in a computer circuit has voltages (DC direct current):
@ +12 Volt for a disk drive,
@ + or -5 Voltor + or -3 Volt for buses and communications wiring,
@ 0.75 1.4 Volt for the processor (depending on the specification, clock speed)
5
What is Information to a Computer? (3)
Whatever the voltage the flow can be switched on and off or be present or absent.
Voltage on might equal a 1,
Voltage off might equal a 0. Binary!
All information (instructions, data, etc.) flows through the hardware system as Power On or Power Off as 1s and 0s.
6
Decimal Numbers
Numbers are often represented in decimal form for our mathematical use.
This is the Base 10 number system and it is the number format that we, as humans, might feel most comfortable with.
Decimal is Base 10
7
Binary Numbers
Computing machines operate on electrical current and so use two states. We view these states as the numbers 0 and 1.
This is the binary representation and is called Base 2.
Binary is Base 2
8
Binary Numbers (2)
All modern computers work with a system of numbers that are binary numbers.
The two symbols: 0 and 1.
Each is called a bit, short for binary digit.
9
Numbers and Their Bases
10
Part b. of this diagram has 1011 in Base 2. That is equal to 11 in Base 10. (An eight plus no four is eight, plus a two is ten, plus a one is eleven.)
Decoding the Binary Representation 1001012
Whether in decimal or binary, the position of numbers delineate their quantity.
The following diagram shows the number positions for binary 100101
11
12
This diagram shows how 1001012 = 3710.
10 01 01
Algorithm for Finding the Binary Representation of a Positive Integer
Step 1.Divide the value by two and record the remainder.
Step 2.As long as the quotient obtained is not zero, continue to divide the newest quotient by two and record the remainder.
Step 3.Now that the quotient of zero has been obtained, the Binary representation of the original value consists of the remainders listed from right to left in the order they were recorded.
13
Obtaining the Binary Representation of 1310
14
Bytes
A group of bits (binary digits), often eight, make up a byte.
A byte can represent a number in the range 0 9, or a letter of the alphabet or a symbol, such as * or ! or , when a binary byte needs to be sent through the central processing unit for a calculation or for storage.
15
Bytes (2)
The highest representation for a number begins on the left side of the binary grouping similar to how, in a decimal number, the position for hundreds is left of the tens position (which is left of the units).
The leftmost position in binary and decimal represents the height of the value of the number.
16
Bytes (3)
17
Bytes in Memory
18
Counting in Binary
19
Binary
Each number has a unique representation.
Counting:
When you run out of digits, make it a zero and increment the next place value to the left.
112 becomes 1002
Decimal
Each number has a unique representation
Counting:
When you run out of digits, make it a zero and increment the next place value to the left.
9910 becomes 10010
Binary Mathematics
The fact that data are represented in binary allows a computer to convert numbers, as data elements, by the mathematical operations of programmed addition, subtraction, multiplication and division.
20
Binary Mathematics (2)
For binary machines (computers) it is usually impossible to do subtraction and division.
It is more feasible for binary numbers to be added to each other to allow any required conversion of a number even when effecting a subtraction, multiplication or division. (This seems odd, but it is how relay devices do (and must) work.
21
Binary Mathematics (3)
For that reason the mathematics of binary are based on increments and decrements.
For example, 2 x 3 would be processed as 00000010 incremented by itself three times. That would be:
00000010
+00000010
+00000010
= 00000110 (000001102 = 610)
22
Binary Mathematics (4)
A binary addition example for single binary digits:
0101
+0+0+1+1
011 10in Base 2
23
Binary Mathematics (5)
A 02 added to a 02 will equal 02
A 02 added to a 12 will equal 12
A 12 added to a 02 will equal 12
A 12 added to a 12 will equal 102
24
Binary Mathematics (6)
*** Note ***
Decrements in binary mathematics are achieved, not by simple subtraction, but by the addition of a negative number!
What!?
This is Twos Complement more on that next
25
Twos Complement
Negative numbers are represented, in binary, by Twos Complement.
To decrement in binary you find the Twos Complement for the number you wish to decrement by (or subtract) and ADD it to the number from which the subtraction must be made.
26
Twos Complement (2)
This looks mad but it is the most efficient and reliable way to reduce the value of numbers (or to create a new number based on subtraction) when operating in binary number form.
27
Representing Negative Numbers
Here is an example of Twos Complement (or 2s complement). Let us say that we have a minus twelve (-12) in Base 10. Do we use 001100 in binary and put an ASCII value for (the minus sign, which is 0101101) in front of it or behind it?
No. Why? Because we would not be able to perform mathematical additions with that combination. It might be all right for representing a text label, but mathematics would not work.
28
Representing Negative Numbers (2)
So
To convert 1210 to 2s complement using 6 bits (to represent -1210):
Decide upon the number of bits n (6).
Find the binary representation of the +ve value in n-bits (0011002).
Flip all the bits (change 1s to 0s and vice versa) (1100112).
Add 1 (1101002)
-1210 = 1101002
29
Representing Negative Numbers (3)
Why does this work?
Look at this:
13 (0011012)
12(1101002) (binary for 12 in 2s comp.)
= 01(0000012)
30
Representing Negative Numbers (4)
The proof is that you take the +13 and ADD the -12.
(0011012)
+(1101002)
1(0000012)
That last 1 on the left gets pushed out and is ignored.
31
Representing Negative Numbers (5)
What happened to Most Significant Bit as of the left-hand side? Well, in this case a pushed 1 becomes an INSIGNIFICANT Bit.
As it happens, using a six-bit capacity means that it is not stored and goes nowhere. It disappears ceases to exist leaving the proper sum, the one you want, 000001, also known as 110.
32
More 2s Complement
Here are more examples for 2s complement:
33
Octal and Hexadecimal Number Bases
Octal and hexadecimal data types are integer types that are available in most computer languages.
All integer values (decimal numbers, with or without decimal places) are expressed in computer memory by setting the values of binary digits for that decimal number.
However, long binary digit sequences that represent large decimal numbers are difficult for us to deal with.
34
Octal Representation
Suppose that you wanted to write out the binary form of the decimal number, 9587. You should find that:
958710 = 100101011100112
The expression can be made more readable by grouping the digits.
35
Octal Representation (2)
Grouping the above binary digits into threes it looks like this:
958710 = |010|010|101|110|0112
(Where the | is used as a divider between groups of three and a zero has been added to fill out the group on the left end.)
36
Octal Representation (3)
The octal notation for representing Binary numbers uses groups of three bits:
Note that the symbols that are used to represent each group are the same as the integer value of each group.
37
Octal Representation (4)
Continuing the Octal notation for Decimal numbers would look like this:
810 is 001 000 and is 10 in Base 8
910 is 001 001 and is 118
1010 is 001 010 and is 128
1110 is 001 011 and is 138
38
Octal Representation (5)
By using these Octal symbols (0 7), the number can be expressed in a more compact form:
958710 = (2|2|5|6|3) in Octal
That is to say
|010|010|101|110|0112can be seen as:
39
Octal Representation (6)
Because the symbols are the same as those that are used in Base 8 counting, this is called octal notation.
We can write:
958710 = 225738
40
Hexadecimal Representation (Hex)
Suppose that we group the binary digits into fours. Then this might be written:
958710 = |0010|0101|0111|00112
Now the groups of four can be given different symbols.
41
Hex Representation (2)
There are 16 different combinations of four binary digits.
The symbols chosen are the common numerals (0 9) and the remaining six possible four-bit combinations are represented by the letters, A, B, C, D, E and F.
(The letters may be either upper or lowercase.)
42
Hexadecimal Representation (3)
The Symbol Table:
43
Hex Representation (4)
With this notation we would write the Base 10 (decimal) number equal to the Base 16 number like this:
958710 = 257316
This is called the hexadecimal representation.
44
Hexadecimal Representation (5)
Proof:
|0010|0101|0111|00112
45
Hex Representation (6)
Hex (short for hexadecimal) is very similar to octal in its relationship to binary. It just takes one more binary column to account for one Hex column.
Since the binary number 1111 equals Hex F, it follows that 1111 1111 binary equals Hex FF.
46
Hexadecimal Representation (7)
Hex has numerals going up to F so you have to be able add single digits up to F before carrying.
For instance, in decimal 7 + 4 would equal 11, and in octal it would equal 13, as in the octal examples above. In hexadecimal it equals B.(1110 = 10112 = B16)
47
Hex Representation (8)
To do these conversions in your head requires that you learn a new addition table (or figure it out on your fingers every time).
Hex is very commonly used in computers because exactly two Hex digits represents exactly eight binary digits, and eight bits are exactly one byte; a common unit of computer numbering.
48
Hexadecimal Representation (9)
Hexadecimal is easier for byte groupings.
Here are some more Hex representations:
1510 is 1111 and is F in Base 16
1610 is 0001 0000 and is 1016
2510 is 0001 1001 and is 1916
18310 is 1011 0111 and is B716
49
End of Number Bases
That describes the mathematical nature of the number bases of decimal, binary, octal and hexadecimal representation. There has been a strong hint that these number bases have practical applications for computer architecture.
Are there
ANY QUESTIONS?
50
Where to Next?
NEXT WEEK:
The theme of the next lecture:
Logic Gates
How do binary numbers move inside a computing device? How are electrical signals used to filter or change the states of bits? We can look at these things next.
51
Thanks for your attentiveness.
See you here next time. Be safe and well in the meantime.
52
0
Bits 000 001 010 011 100 101 110 111
Octal 0 1 2 3 4 5 6 7
Bits
000
001
010
011
100
101
110
111
Octal
0
1
2
3
4
5
6
7
010 010 101 110 011
2 2 5 6 3
010
010
101
110
011
2
2
5
6
3
0010 0101 0111 0011
2 5 7 3
0010
0101
0111
0011
2
5
7
3
/docProps/thumbnail.jpeg
Reviews
There are no reviews yet.