How information is represented in computers

Download Report

Transcript How information is represented in computers

Transforming Data
into Information
This lesson includes the following
sections:
• How Computers Represent Data
• How Computers Process Data
How Computers Represent Data
• Binary Numbers
• The Binary Number System
• Bits and Bytes
• Text Codes
How Computers Represent Data
– Binary Numbers
•
Computer processing is performed by transistors,
which are switches with only two possible states: on
and off.
•
All computer data is converted to a series of binary
numbers – 1 and 0. For example, you see a sentence
as a collection of letters, but the computer sees each
letter as a collection of 1s and 0s.
•
If a transistor is assigned a value of 1, it is on. If it has
a value of 0, it is off. A computer's transistors can be
switched on and off millions of times each second.
The Binary Number System
• To convert data into strings of
numbers, computers use the binary
number system.
• Humans use the decimal system
(“deci” stands for “ten”).
• The binary number system works the
same way as the decimal system, but
has only two available symbols (0 and
1) rather than ten (0, 1, 2, 3, 4, 5, 6, 7,
8, and 9).
Base 10
Base 2
0
1
2
3
4
5
6
7
0
1
10
11
100
101
110
111
8
9
10
1000
1001
1010
Different Number Representations
• Algorithms are central to computing, and are well defined
procedures for solving problems.
• Any algorithm involves operations on symbols
(representations) over some domain.
• There can be NO operation without a representation.
• Our adopted number notation has
(1) a base of 10 (determines the magnitude of a place).
(2) the value of a digit depends on its position (digit x Baseposition)
(3) is restricted to 10 re-usable digits
the 5 in 25 = 5 x 100 = 5
the 5 in 51 = 5 x 101 = 50
the 5 in 4538 = 5 x 102 = 500
Representations and Operations
Given the adoption of the Hindu-Arabic representation of
numbers, this defines the algorithms for performing operations.
For instance the addition of 2 digits which overflows the
representation, causes a "carry" to occur, and this is an
increment of the digit in the next place value.
the Roman number system doesn't use place value
• relies on a repetition of symbols, eg. CCLXXXII for 282.
• the order of the digits had no meaning (originally).
With this representation what was the operation of addition?
Binary Representations and Operations
The representation in binary follows the same rules as decimal.
110(binary) = 1 x 22 + 1 x 21 + 0 x 20 = 6(decimal)
Binary Arithmetic
Operation using binary are the same as decimal, but with the
following simple rules.
0+0 = 0
0+1 = 1
1+0 = 1
1 + 1 = 0 with a carry of 1
Binary Addition
Decimal Addition
1
1 1 0
= 6
11 1 1
= 7
1 1 0 1
= 13
Why use a binary system in a computer?
Reliability and Binary Systems
We use binary because we can more reliably engineer
computer systems.
Binary data is represented by the state of a electrical
switches. Switches have only two states, on or off,
measured as a high voltage or a low voltage.
Decimal data would require an electrical device capable of
consistently differentiating between ten states. A less
reliable system.
Babbage had the same problems with his “mechanical”
computers. Precision machining of “decimal” cogs was
difficult.
How Computers Represent Data - Bits and Bytes
•
A single unit of data is called a bit, having a value of 1
or 0.
•
Computers work with collections of bits, grouping
them to represent larger pieces of data, such as letters
of the alphabet.
•
Eight bits make up one byte. A byte is the amount of
memory needed to store one alphanumeric character.
•
With one byte, the computer can represent one of 256
different symbols or characters.
.
1 01
10
1 01
01 1 01
How Computers Represent Data - Text Codes
•
A text code is a system that uses binary numbers (1s
and 0s) to represent characters understood by humans
(letters and numerals).
•
An early text code system, called EBCDIC, uses eightbit codes, but is used primarily in older mainframe
systems.
•
In the most common text-code set, ASCII, each
character consists of eight bits (one byte) of data.
ASCII is used in nearly all personal computers.
•
In the Unicode text-code set, each character consists of
16 bits (two bytes) of data.
Examples from the
ASCII Text Code
Code
Character
00110000
00110001
00110010
00110011
00110100
00110101
01000001
01000010
0
1
2
3
4
5
A
B
01000011
01000100
01000101
C
D
E
How Computers Process Data
Where Processing Occurs:
•
The Control Unit
•
The Arithmetic Logic Unit
•
Machine Cycles
How Computers Process Data –
Where Processing Occurs
•
Processing takes place in the PC's central processing
unit (CPU).
•
The system's memory also plays a crucial role in
processing data.
•
Both the CPU and memory are attached to the
system's motherboard, which connects all the
computer's devices together, enabling them to
communicate.