CSC Week 2
CSC Week 2
CSC Week 2
ng
There are three ways of representing information or data in computer system. These are as
follows:
Number System
Character codes
Logic gates and Truth Table
Number Systems include Binary number, Octal number, Hexadecimal number, Binary Fraction,
Arithmetic operation, Negative numbers, Fixed-point and Floating Point representation and
Errors.
Binary Number – This method is used to represent information with two-state circuits. These
two states are 0 or 1. These two states are used in computer because they are quick, reliable and
take up only small amounts of space and energy. They are called binary digits or bits.
= 0+4+2+0
01102 = 610
2 6
2 3 remainder 0
2 1 remainder 1
0 remainder 1
http://www.unaab.edu.ng
610 = 01102
8 49
8 6 remainder 1
0 remainder 6
4910 = 0618
0 x 8 2 + 6 x 81 + 1 x 80
0 + 48 + 1 = 4910
Octal 7 4
Binary 111 100
748 = 111002
327610 to base 8
8 3276
8 409 rem. 4
8 51 rem. 1
6 rem. 3
1100110011002 = 6314
Another method is to use the group binary digits where each number is converted to its binary
equivalent.
6 3 1 4
http://www.unaab.edu.ng
2 2 0010
3 3 0011
4 4 0100
5 5 0101
6 6 0110
7 7 0111
8 8 1000
9 9 1001
10 A 1010
11 B 1011
12 C 1100
13 D 1101
14 E 1110
15 F 1111
Hexadecimal Numbers
Convert from Decimal to Hexadecimal
7710 to Hex.
16 77
4 R 13D
= 4DH
4 x 161 + 13 x 160
64 + 13 = 77
Hexadecimal Number 4 D
Binary Equivalent 0100 1101
1 1 5
4DH = 1158
1 12 10
1110010102 = 1CAH
Binary Fraction
2-1 2-2 2-3 2-4
½ ¼ 1/8 1/16
= 1 x 1/2 + 0 + 0 + 0
= ½+0 +0+0
½ = 0.5
0+1x¼+0+0
¼ = 0.25
0.125 to binary
0.125 = .001
Computer Arithmetic
The arithmetic and logic unit of the central processor in a computer performs all its arithmetic by
addition and shifting.
+710 01112
1510 11112
Binary multiplication
510 - 1012
210 - 0102
- 000
101
http://www.unaab.edu.ng
000
1010 10102
Binary Division
810/410 = 210
10002/1002 = 102
Negative Numbers
There are several common methods for representing negative numbers on computers including
(a) Sign-magnitude
7 = 00000111
21 = 00010101
The sign magnitude representation makes it to obtain the magnitude and the negative of a
number. The magnitude is obtained by clearing the most significant bit and the negative by
inverting the most significant bit. The sign magnitude representation is frequently used in Analog
to Digital and Digital to Analog conversion
One’s Complement
In the one’s complement representation, the negative of a number is the logical complement (that
is, replace all the zeros in the binary representation by ones and all the ones by zero.
e.g.
http://www.unaab.edu.ng
7 = 00000111
21 = 00010101
The problem with one’s complement is that the one’s complement of zero is not zero – that is
0 = 00000000
This confusion has made the one’s complement representation of negative obsolete.
The sign-magnitude representation makes arithmetic difficult because the binary sum of a
numbers and its sign-magnitude negative is not zero.
e.g. 1 = 00000001
26 – 15
store 15 = 001111
reverse 15 = 110000
store 26 = 011010
0010112 = 1110
The overflows bit must be added to the unit column of the sum to give the right answers.
http://www.unaab.edu.ng
Two’s Complement
In the two’s complement representation, the negative of a number is the logical complement plus
one
store 18 = 010010
add 1 1
101110
store 25 011001
0001112 = 710
Fixed point representation: The used way of representing numbers is to write the number with
decimal point fixed digits e.g. 13.75 or 3862.4 This is fixed point representation and it proves
very useful in data processing for example where sums of money are to be processed or printed.
Floating point representation: when representation in fixed point becomes laborious and
cumbersome with several very large or very small e.g. cumbersome with several very large or
very small numbers e.g.
1285000000
0.000000125
0.0000000000036241
The answer is to use floating point representation. The floating means the binary point always
floats to the beginning of the number it is similar to standard form.
http://www.unaab.edu.ng
mantissa base
In some application computer inputs and output of floating point numbers is printed on one line
as shown below
The “E” separates the exponent from the mantissa and base 10 is assumed.
http://www.unaab.edu.ng
ERRORS
At times computer processing and manipulation of data or figures are not producing the correct
results. There is nothing wrong. It is due to shortcoming in company’s arithmetic. There are
several type errors including overflow carry truncation rounding.
Overflow - This error occur when the storage space is two small to store a given number for
example in 8 bit 2's complement the range is 128 to 127 as follows:
26 25 24 23 22 21 20
place value -128 64 32 16 8 4 2 1
Minimum number 1 0 0 0 0 0 0 0
Maximum number 0 1 1 1 1 1 1 1
If the answer to a calculation is outside the range, an overflow occurring. The computer usually
shows an error message and halts the program.
Carry - Most computer have a one bit flag or condition code that saves the carry from the most
significant bit of an addition or subtract. This flag or carry can be used to implement carried or
borrows between words or in multiple precision arithmetic.
E.g. Add 10110001 10011100
+ 00001001 11100001
using 8-bit arithmetic
Step 1 Add the least significant eight bits of the numbers
10011100
Carry 11100001
101111101
Step 2 Add the most significant eight bits of the two numbers plus the carry from step 1 (which
is the least significant bits)
10110001
00001001
1
10111011
so the answer is 10111011 01111101
http://www.unaab.edu.ng
Note that adding 16 bit numbers on an 8-bit computer requires more than two addition since the
second addition must include the CARRY.
Truncation
Truncate means to cut off and truncation error happen when a fraction is cut off a certain number
of decimal or binary places.
Examples:
In base 10
1/3 = 0.33 - truncated to three decimal places
In base 2
1/3 = 0.010101 - truncated to six binary places.
Rounding - To reduce truncation errors fractions in base 10 are round by raising the last figure
by I if the next figure would have been greater in less then 5
Examples:
2/3 = 0.6666 rounded to three decimals places is 0.6667
Truncate (17.5) = 17
Round (17.5) = 18
There are types of codes character code that are commonly used include
- Binary coded decimal
- ASCII code
- ESCDIC Code
Binary coded decimal codes are widely used with microprocessors and calculators. There codes
represent decimal numbers by coding each decimal separately into four bits.
http://www.unaab.edu.ng
ASCII Code
American Standard Code for Information Interchange is a standard code developed in the early
1960s. It is being used in small computers, terminals, peripherals and communication devices.
ASCII code used seven bits to represent each characters. Seven bits give us 27 = 128. ASCII can
represent 128 characters. It is enough to represent the upper and lower case letters, digits, the
punctuation marks and a small number of special signs. ASCII code with 7-bits uses three zone
bits and four numeric bits to represent characters. ASCI code with 8-bits adds one bit as parity
checking.
SO RS . > N ^ n ~ 1 1 1 0
SI US / ; O - o DEL 1 1 1 1
EBCDIC code: The name stands for Extended Binary Coded Decimal Interchange Code. IBM
developed this code for use on its computers. In EBCDIC 8 bits represent each character. Eight
bits gives us 28 = 256. In EBCDIC 256 characters can be represented. This is twice of ASCII.
IBM minicomputers and mainframe computers and some mainframe computers that are similar
to IBM, use the EBCDIC code. The eight bits can be divided into two zones - Zone bit and
numeric bit which both have four bits each.
The EBCDIC representation can be summarised as follows:
3.0 SOFTWARE
Software is the term used (in contrast to Hardware) to describe all programs that are used in a
particular computer installation. Software is the program, which directs the operations of a
computer or a program or set of programs that tell the computer what to do.
There are two basic types of software:
System Software
Application Software
Operating Systems (OS) and control programs are means by which computer monitor and
control their own operation where possible in order to give efficient and reliable service without
the need for continual intervention by the user.
Apple Mac
Os/2
Open System.
http://www.unaab.edu.ng
It convert code written in a programming language into the form understood by the
computer.
The language on which translation takes place is known as source program where the newly
translated place is known as object program, this is often machine-code or equivalent.
There are three types of translating program, namely:
Assemblers
Compilers
Interpreters
Assembler: A program that translates a low-level language into machine code. One machine
instruction is generated for each source instruction. The resulting program can only be executed
when the assembly process is completed.
The assembler:
Translates mnemonic operation codes into machine code and symbolic addresses into
machine addresses.
Includes the necessary linkages for closed subroutines and inserts appropriate machine code
for macros.
Allocates areas of storage.
Detect and indicates invalid source-language instructions.
Produced the object program on tape or disk as required.
Produces the printed listing of the source and object program with comments. The listing
may also include error codes if appropriate.
http://www.unaab.edu.ng
The Compiler:
Interpreter: A program that translates and executes each source statement in logical sequence as
the program is executed. The interpreter deals with the source program one instruction at a time,
completely translating and executing each instruction before it goes to the next.
They are system programs that provide useful service to the user of the computer by providing
facilities for performing common tasks of a routine nature. Common types of utility programs
are as follows:
SORT
EDITORS
FILE COPYING
http://www.unaab.edu.ng
DUMP
FILE MAINTENANCE
TRACING AND DEBUGGING
SORT: A program designed to arrange records into a predetermined sequence. A good example
of the requirement for this service program is the need for sorting transaction files into the
sequence of the Master file before carrying out updating. Sorting is done by reference to a record
key.
EDITORS: are used at a terminal and provide facilities for the creation or amendment of
programs. The editing may be done by the use of a series of commands or special edit keys on
the keyboard. If for example, a source program needs correction because it has failed to compile
properly, an editor may be used to make the necessary changes.
FILE COPYING: This is a program that simply copies data from one medium to another e.g.
from disk to tape.
DUMP: The term “DUMP” means, “copy the contents of main storage onto an output device”.
This program is useful when an error occurs during the running of application programs. The
printed “picture” of main storage will contain information helpful to the programmer when
trying to locate the errors.
TRACING & DEBUGGING: This is used in conjunction with the debugging and testing of
application programs on the computer. Tracing involves dumping internal storage after obeying
specified instructions so that the cycle of operations can be traced and error located.
Debugging is the term given to the process of locating and eliminating errors from a program.
DATA BASE MANAGEMENT SYSTEM (DBMS): This is software that builds, manages and
provides access to a database, allowing a systematic approach to the storage and retrieval of data.
http://www.unaab.edu.ng
User application programs are programs written by the user in order to perform specific jobs for
the user. Such programs are written in a variety of programming languages according to
circumstances, but all should be written in a systematic way as indicated in the parts of
programming. For many applications, it is necessary to produce sets of programs that are used in
conjunction with one another and that may also be used in conjunction with service programs
such as sort utilities.
Application Packages
Application packages are ready-made programs written to perform a particular job. The job will
be common to many potential users, so that the package could be adopted by all of them for
their data processing operations. The package should be fully documented and the
documentation should include specifications of input and output formats and file layout, user
instruction Manual, hardware requirements and details of how the package may be varied to suit
the users individual needs.
http://www.unaab.edu.ng
k. HOW MANY OTHER USERS HAVE BOUGHT THE PACKAGE, AND HOW LONG
HAS IT BEEN ON THE MARKET? New package might offer enhanced facilities, whereas
well-established packages are more likely to be error free.
l. WILL THE PACKAGE RUN ON THE USER’S COMPUTER? Will additional peripheral
equipment have to be bought – e.g. does the package need a hard disk file, when the
computer user only has floppy disk drive with his micro?
m. WHAT SUPPORT AND MAINTAENANCE SERVICE will the software supplier provide,
in the event that the user has difficulty with the package?
n. COMPARATIVE COST OF DIFFIRENT PACKAGES SHOULD BE A LOW PRIORITY.
A Company should really buy what it needs for efficient operations rather than the least-cost
packages available. However, the package most not cost so much that the costs are greater
than the benefits of having it.
The AND and OR gates have two or more inputs and a single output. The inverter is a logic gate
that has a single input and a single output and whose output is the logical complement of the
input. When the input is true, the output is false and vice versa.
A B Z = A AND B A B Z = A OR B
0 0 0 0 0 0
0 1 0 0 1 1
1 0 0 1 0 1
1 1 1 1 1 1
http://www.unaab.edu.ng
PROGRAMMING LANGUAGES
A Computer works by executive a series of instruction. These series of instruction are called a
program. A program can be written in variety of programming languages. As at beginning of
year 2000, there are five generations of Programming Languages. They are as follows:
- Machine programming language
- Assembling programming language
- High-level programming language
- Machine Independent programming language
- Natural Language programming language
Machine Language – A manufacturer designs a computer to obey just one language. This is a
machine code, which is represented inside the computer by combinations of binary digits.
Writing programs in machine language is very difficult. The programmer must remember binary
codes and numbers.
1 8 3 5
Advantages
– It uses computer’s storage more efficiently.
– It takes less time to process in a computer than any other programming languages.
Disadvantages
- It is time consuming
- It is very tedious
- It is subject to human error
- It is expensive in program preparation and debugging stages.
http://www.unaab.edu.ng
Assembly Language – After using machine language for a while, computer researchers looked
for solution of replacing binary form with words and symbols. Assembly language permits
symbols rather than only number to be used in writing instructions.
Assume 10 is the function code for Jump in a machine code instruction set, 10000111 would
therefore mean Jump to location 7.
Advantage
- It is more efficient than machine language
- Symbols make it easier to use than machine language
- It is useful to write system programs, word processor spreadsheet, data base management
program etc.
- It may be useful for security reasons.
Advantages
- they are similar to English with vocabularies of words and symbols.
- The symbols are easy to learn and use.
The use of natural language touches an expert systems or artificial intelligence. Expert system is
a computerised collection of the knowledge of many human experts in a given field. Artificial
intelligent is an independently smart computer system.