Data Types and Representation

Download Report

Transcript Data Types and Representation

Data Types and Representation
CS French
Chapter 6
+ Chapter 7 – Number Bases
Data Processing
Data
eg ESB meter
readings
Processing
by
Computer
Maintained Data
eg names, addresses,
account numbers, last
meter reading,
amount already owed.
INFORMATION
eg bills
Scientific Processing


Data
eg current
weather
conditions
Processing
by
Computer
Large amount of
calculations of changes
over small distances
and time periods.
INFORMATION
description of
tomorrow’s
weather
Basic Data Types

Data is represented by the character set
Р0..9,a...z,A....Z, !ӣ$%.()~ etc

Character Types
– Numeric 0...9
– Alphabetic (upper and lower case)
– Special

Data Types
– Numeric
» signed/unsigned integers, real, fised / floating point
– Alphabetic
– Alphanumeric
Data Representation for
Computer Devices

Punched Paper tape (obsolete)
7 8 9 0 a b c d e f g h i j k l m n o p
This tape is using the ASCII coding system.


Binary Devices
Punched tape can be replaced by any device that contains items
that can be set to any one of two positions.
Magnetic tape/disc
– spots can be magnetised one direction NORTH or the other SOUTH

Transistors
– Electronic switches that can be ON or OFF

Charged cells
– An electronic device that can have a NEGATIVE or POSITIVE charge

Reflective surface (CD)
– Spots on the disc may REFLECT a thin laser light or NOT REFLECT it


These devices are called Binary devices (or two state devices)
because when writing the data on paper we can use the digits 1 and
0 to represent the two states.
A single piece of information is called a BIT (Binary digIT)
– One item in the device is required to store a bit (a switch, a hole, a magnetic
spot, a reflective spot etc.)
Some ASCII Codes
Binary Code
00100000
00100001
00110110
00110111
01000001
01000010
01100001
ASCII Character
SPACE
!
6
7
A
B
a
How many possible characters can be represented with 8 bits?
Data Transmission
5
0
1
1v
5v
Could you use this electrical circuit and the ASCII code system to send a
message?
Use the 5 volt position to represent 1 and the 1 volt position to represent 0. The
person at the other end will see a series of bright and dim lights which can be
interpreted as ones and zeros and which can then be translated into characters
using the ASCII table.
Why is the 0 volt position in the switch necessary?
If you are transmitting 2 ones or zeros consecutively you can momentarily switch
the light off to distinguish between them.
Or if you used 0 volts to represent 0 you wouldn’t be able to tell the difference
between a 0 being transmitted and ‘no signal’ being transmitted.
Pulse Train for ASCII ‘K’
Voltage
5
1
0100 10 1
1
Time
If you measured the voltage in the wire and graphed how it changed over time.
What is the advantage of having each bit the same length?
You don’t have to break the signal between 2 ones or zeros.
Parity
(not required for 1st year course)

An extra bit is added to each code if required
in order to ensure there is an ODD number of
1’s in the code.(odd parity)
7 8 9 0 a b c d e f g h i j k l m n o p
•You can also use even parity
•Used to detect errors in data storage or transmission
Bit Mapped Images
Digitised Sound
Sampling : a voltage generated by the sound vibrations in a sensor (eg. Microphone) is
recorded as numbers at discrete intervals.
Reconstructed sound: the sound wave form can be recreated from the recorded numbers.
Notice there is a loss of detail between the measurements.
Chapter 7: Number Bases
Decimal Octal Hexadecimal Binary
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
1
2
3
4
5
6
7
10
11
12
13
14
15
16
17
20
21
22
23
24
25
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
10
11
12
13
14
15
1
10
11
100
101
110
111
1000
1001
1010
1011
1100
1101
1110
1111
10000
10001
10010
10011
10100
10101
Think about how you count!
It is easier to
convert from binary
to octal or
hexadecimal than to
decimal!
Conversions
fours ones
1101
Binary to decimal:
eights twos
Decimal to binary:
2
2
2
2
2
2
21
10
5
2
1
0
1x1 = 1
0x2 = 0
1x4 = 4
1x8 = 8
Total 13
leftovers
1
0
1
0
21 = 10101
1