Computer Number System
Computer Number System
1
Data Processing
Is the process of converting data in to information? The process usually assumed to be
automated and running on a personal computer (Generally information communication
technology). More generally the term data processing can apply to any process that
converts data form one formats to another ; for this perspectives , data processing
becomes the processes of converting data in to information and also the converting of
information back in to data.
Data processing
Addition Disseminating
Subtraction
Input Division
Out put
Row data multiplication
Processed data
sorting (information
expertise knowledge
Classification etc...
Storing
Storing Storing
For later processing For later use 2
Information source
Information sources generally categorized in to two broad categories. These are
1. Documentary information sources: those information sources which we normally
obtain them either in paper printed format or electronically recorded format.
Documentary information sources again categorized in to three groups.
o Primary documentary information sources: - they are original material.
They are from the time period involved and have not been filtered through
interpretation. Examples of primary information sources are
Diaries
Interviews( legal proceedings, personal, telephone, e-mail)
Letters
Original document
Patents
Photographs
Proceedings( meeting, Conference, and Symposia)
Survey research
Works of Literature
o Secondary sources: are accounts written after the fact with the benefit of
hindsight. They are interpretation and evaluations of primary sources.
Secondary sources are not evidence, but rather commentary on and discussion
of evidence. Examples of secondary information sources are
Scholarly periodicals
Books
Text books
Commentaries
Monographs
o Tertiary information sources: consists of information which is a distillation
on collection of primary and secondary sources.
Almanac
Encyclopedias
Fact books
Indexes(used to locate primary and secondary information sources)
3
2. Non-documentary information sources. Those information sources which don’t
recorded in any format. E.g. public speech, informal talks with friends, discussion
group etc…
o Formal : an information sources from formal meetings , conferences
o Non formal: informal communication with friends, discussion group etc…
We know that the computer is an electronic device ie it works using electrical signals. Electrical
signals can represent only two states; on and off. (E.g. an electric bulb). So any information that
has to be processed by a digital computer has to be converted in to a format which has two states.
So in digital information processing we use the binary number system which has two digits.
4
beginning at the least significant digit (right) and each new digit is written to more significant
digit (the left) of the previous digit. Consider the number 2671.
2671 / 2 1335 1 1
1335 / 2 667 1 11
166 / 2 83 0 0 1111
83 / 2 41 1 10 1111
41 / 2 20 1 110 1111
20 / 2 10 0 0110 1111
10 / 2 5 0 0 0110 1111
5
Weighted Value Subtraction Remainder Binary Number
Bit 1 1
Nibble 4 0101
Double Word 32 0000 0000 0000 0000 0000 0000 0000 0101
6
In any number base, we may add as many leading zeroes as we wish without changing its value.
However, we normally add leading zeroes to adjust the binary number to a desired size boundary.
For example, we can represent the number five as:
Bit 101
Nibble 0101
The Bit
The smallest "unit" of data on a binary computer is a single bit. Since a single bit is capable of
representing only two different values (typically zero or one).
The Nibble
A nibble is a collection of bits on a 4-bit boundary.
The Byte
A byte also contains exactly two nibbles. Bits b0 through b3 comprise the low order nibble, and
bits b4 through b7 form the high order nibble.
The Word
A double word is exactly what its name implies, two words. Therefore, a double word quantity is
32 bits. Naturally, this double word can be divided into a high order word and a low order word,
four bytes, or eight nibbles.
7
Hexadecimal Number System
A big problem with the binary system is verbosity. To represent the value 202 requires eight
binary digits.
The decimal version requires only three decimal digits and, thus, represents numbers much more
compactly than does the binary numbering system. This fact was not lost on the engineers who
designed binary computer systems.
When dealing with large values, binary numbers quickly become too unwieldy. The hexadecimal
(base 16) numbering system solves these problems. Hexadecimal numbers offer the two features:
Hex numbers are very compact
It is easy to convert from hex to binary and binary to hex.
The Hexadecimal system is based on the binary system using a Nibble or 4-bit boundary. We
place an H at the end of the number to denote the number base.
The Hexadecimal Number System:
uses base 16
includes only the digits 0 through 9 and the letters A, B, C, D, E, and F
In the Hexadecimal number system, the hex values greater than 9 carry the following decimal
value:
8
1001B 11Q 09 09H
This table provides all the information you'll ever need to convert from one number base into any
other number base for the decimal values from 0 to 16.
To convert a hexadecimal number into a binary number, simply brake the binary number into 4-
bit groups beginning with the LSB and substitute the corresponding four bits in binary for each
hexadecimal digit in the number.
For example, to convert 0ABCDh into a binary value, simply convert each hexadecimal digit
according to the table above. The binary equivalent is:
To convert a binary number into hexadecimal format is almost as easy. The first step is to pad the
binary number with leading zeros to make sure that the the binary number contains multiples of
four bits. For example, given the binary number 10 1100 1010, the first step would be to add two
bits in the MSB position so that it contains 12 bits. The revised binary value is 0010 1100 1010.
The next step is to separate the binary value into groups of four bits, e.g., 0010 1100 1010.
Finally, look up these binary values in the table above and substitute the appropriate hexadecimal
digits, e.g., 2CA.
The weighted values for each position is as follows:
4096 256 16 1
9
Binary to Hex Conversion
It is easy to convert from an integer binary number to hex. This is accomplished by:
1. Break the binary number into 4-bit sections from the LSB to the MSB.
2. Convert the 4-bit binary number to its Hex equivalent.
For example, the binary value 1010111110110010 will be written:
A F B 2
A F B 2
This yields the binary number 1010111110110010 or 1010 1111 1011 0010 in our more readable
format.
Hex to Decimal Conversion
To convert from Hex to Decimal, multiply the value in each position by its hex weight and add
each value. Using the value from the previous example, 0AFB2H, we would expect to obtain the
decimal value 44978.
10
remainder until the quotient is 0. When performing the division, the remainders which will
represent the hex equivalent of the decimal number are written beginning at the least significant
digit (right) and each new digit is written to the next more significant digit (the left) of the
previous digit. Consider the number 44978.
44978 / 16 2811 2 2
2811 / 16 175 11 B2
175 / 16 10 15 FB2
10 / 16 0 10 0AFB2
As you can see, we are back with the original number. That is what we should expect.
When you use hex numbers in an 8085 program, the Assembler usually requires the most
significant hex digit to be 0 even if this number of digits exceed the size of the register. This is an
Assembler requirement and your value will be assembled correctly.
11
For example, the binary value 1010111110110010 will be written:
1 2 7 6 6 2
1 2 7 6 6 2
This yields the binary number 001010111110110010 or 00 1010 1111 1011 0010 in our more
readable format.
Octal to Decimal Conversion
To convert from Octal to Decimal, multiply the value in each position by its Octal weight and add
each value. Using the value from the previous example, 127662Q, we would expect to obtain the
decimal value 44978.
12
Division Quotient Remainder Octal Number
44978 / 8 5622 2 2
5622 / 8 702 6 62
702 / 8 87 6 662
87 / 8 10 7 7662
10 / 8 1 2 27662
1/8 0 1 127662
As you can see, we are back with the original number. That is what we should expect.
13
CODING METHODS
There are different coding systems that convert one or more character sets into computer
codes. Examples are BCD and ACSII
BCD (4-bits)
Coding Examples
81 1000 0001
935 1001 0011 0101
ASCII-7
14
Coding exemples:
ASCII-7
Character Zone digit
$ 010 0100
% 010 0101
A 100 0001
a 110 0001
b 110 0010
Coding Examples
15
Representation of Numbers
Negative Numbers
All the numbers you've looked at so far have been positive whole numbers. There is no
equivalent in binary to the minus sign so other ways have been devised to represent
negative values. The two most widely used are:
When a value is represented using sign and magnitude, the left hand bit, the most
significant bit, is used solely to determine the sign of the number.
For example:
1010 = -2
0010 = +2
Activity:
Solution
The magnitude of a number 4 in binary is 100, since the number is negative add 1 to the
left most position of the number; hence 1100
16
Decimal number Sign bit Magnitude Sign Magnitude
representation
+4 0 100 0100
-4 1 100 1100
+5 0 101 0101
-5 1 101 1101
This means that a 4-bit number cannot represent any value greater than 7 because the 4th
bit is used to indicate the sign. However the 4 bits can still represent 15 different values
when the negative numbers are included. These values are:
-7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7
If there was no sign bit, 4 bits would represent the following 16 values:
0, 1, 2, 3, 4, 5 , 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
Activity
Can you work out why there are only 15 values when you use sign and magnitude but 16 when there is no
sign bit?
Two's Complement
Decimal arithmetic uses different operations for addition and subtraction. Using two's
complement, subtraction is carried out using the machine operation for addition. This
system works for bit strings of any length. The examples given will use 8 or 4-bit strings
for simplicity but a working PC is likely to use 32 or 64-bit strings. The first bit is again
used to indicate a negative value but it also bears the position value.
17
Converting a number to its negative form is a two-stage process:
1. Complement (invert) all the bits (the result at this stage is known as one's
complement).
2. Add 1.
If you're working with 8-bit strings all values must appear as 8 bits and the possible
values will be in the range -128 to 127.
Example
Using a 4-bit binary string
To convert 1101 (1310) to its negative:
18
Activity:
The table below shows the two's complement representation of the range -8 to + 7
When 1 is added to the binary representation for -1 the result is a 5-bit number. Because
the machine has only allocated 4 bits, the 5th bit is ignored as overflow. This same
process can be used to convert negative numbers to positive. This ability to treat positive
and negative numbers in the same way is the reason that two's complement is the most
commonly used machine representation for negative numbers.
19
Boolean algebra
Definition:
Boolean algebra is an algebra that deals with binary numbers.
2. logical addition
The symbol “+” is used for logical addition. It is also known as “or” operator.
The resulting out put values four each of the four (since the variable in the equation say A
and B can have only two possible values (0 and 1) so only four (22 ) combination of input
are possible) input combinations are given in the following table
3: logical multiplication
The symbol “.” is used for logical multiplication. It is also known as “and” operator.
The resulting out put values four each of the four (since the variable in the equation say A
and B can have only two possible values (0 and 1) so only four (22 ) combination of input
are possible) input combinations are given in the following table
Complementation
The symbol for compliment operator is “-“. It is also known as an inverter.
The compliment of a variable is the reverse of its value.
20
The NOT operation is unlike the OR and AND operations in that it can be
performed on a single input variable. For example, if the variable A is subjected
to the NOT operation, the result x can be expressed as
X = A'
Where the prime (') represents the NOT operation. This expression is read as:
x equals NOT A
x equals the inverse of A
x equals the complement of A
Each of these is in common usage and all indicate that the logic value of x = A' is
opposite to the logic value of A.
Operator precedence
21
4. If an expression has a bar over it, perform the operations of the
expression first and then invert the result.
Investigating the various Boolean theorems (rules) can help us to simplify logic
expressions and logic circuits
22
DeMorgan's Theorem
Theorem (16) says that when the OR sum of two variables is inverted, this is the
same as inverting each variable individually and then ANDing these inverted
variables.
Theorem (17) says that when the AND product of two variables is inverted, this is
the same as inverting each variable individually and then ORing them.
Example
X = [(A'+C) * (B+D')]'
= (A'+C)' + (B+D')' [by theorem (17)]
= (A''*C') + (B'+D'') [by theorem (16)]
= AC' + B'D
Boolean function
It is an expression formed with binary variables, the two binary operators and the
unary operator, parenthesis and equal sign.
Example
W=x+ y-.z
23
The above function can also be represented using truth table
0 0 1 1 1 1
0 1 0 0 0 0
0 1 1 0 0 0
1 0 0 1 0 1
1 0 1 1 1 1
1 1 0 0 0 1
1 1 1 0 0 1
Objective:
At the end of this section the learner will be able to:
Define logic gates, Boolean algebra, and logic circuit.
Determine types of logic gates.
Simplify a given Boolean function
Design simple logic circuits.
Evaluate a value of a given logic circuit.
This topic introduces Boolean logic and logic gates. This form of logic is the basis of
current electronic computers, and is also widely used by programmers when writing
systems.
24
Boolean logic is a way of expressing a bit of information as one of two states, TRUE or
FALSE. There are no intermediate states. Typically, TRUE is represented as a small
positive voltage, and FALSE is a zero voltage. Many people think of these two states as
being On and Off.
Definition:
A logic gate is a device that gives a predictable output when given specific
inputs
In an electronic computer the gates are implemented using electronic logic, with modern
systems typically containing millions of these devices integrated into a few silicon chips
appearing on the circuit board.
Boolean 0 and 1 do not represent actual numbers but instead represent the state of a
voltage variable, or what is called its logic level.
Logic 0 Logic 1
False True
Off On
Low High
No Yes
Open Switch Close Switch
OR gate
25
The OR operation produces a result of 0 only when all the input variables are 0.
AND Gate
The AND operation produces a result of 1 occurs only for the single case when all
of the input variables are 1.
The output is 0 for any case where one or more inputs are 0
26
NOT Gate
The NOT operation is unlike the OR and AND operations in that it can be
performed on a single input variable. For example, if the variable A is subjected
to the NOT operation, the result x can be expressed as
X = A'
Where the prime (') represents the NOT operation. This expression is read
as:
x equals NOT A
x equals the inverse of A
x equals the complement of A
Each of these is in common usage and all indicate that the logic value of x
= A' is opposite to the logic value of A.
27
NOR Gate
NOR is the same as the OR gate symbol except that it has a small circle on the
output. This small circle represents the inversion operation. Therefore the output
expression of the two input NOR gate is:
X = ( A + B )'
NAND Gate
NAND is the same as the AND gate symbol except that it has a small circle on the
output. This small circle represents the inversion operation. Therefore the output
expression of the two input NAND gate is:
X = ( AB )'
28
QUIZ Questions
29
3. What is the output X if A=1 and B=0?
a) 0
b) 1
c) I don't know
d) No Answer
4. For a three inputs (A,B C) OR gate, what inputs are needed if output=0?
a) A=0, B=0, C=1
b) A=0, B=1, C=0
c) A=1, B=1, C=1
d) A=0, B=0,C=0
e) No Answer
Logic circuits
Describing Logic Circuits Algebraically
Any logic circuit, no matter how complex, may be completely described using the
Boolean operations, because the OR gate, AND gate, and NOT circuit are the
basic building blocks of digital systems.
Note:
If an expression contains both AND and OR operations, the AND operations are
performed first (X=AB+C: AB is performed first), unless there are parentheses in
the expression, in which case the operation inside the parentheses is to be
performed first (X= (A+B) +C: A+B is performed first).
30
Evaluating Logic Circuit Outputs
Once the Boolean expression for a circuit output has been obtained, the output
logic level can be determined for any set of input levels.
Example:
X = A'BC (A+D)'
= 0'*1*1* (0+1)'
= 1 *1*1* (1)'
= 1 *1*1* 0
=0
Each OR-gate input is an AND product term, which means that an AND gate with
appropriate inputs can be used to generate each of these terms. Note the use of Inverters
to produce the A' and C' terms required in the expression.
31
Universality of NAND & NOR Gates
It is possible to implement any logic expression using only NAND gates and no other
type of gate. This is because NAND gates, in the proper combination, can be used to
perform each of the Boolean operations OR, AND, and INVERT.
32