Data Types and Representation CS French Chapter 6 + Chapter 7 – Number Bases.

14
Data Types and Data Types and Representation Representation CS French CS French Chapter 6 Chapter 6 + Chapter 7 – Number + Chapter 7 – Number Bases Bases

Transcript of Data Types and Representation CS French Chapter 6 + Chapter 7 – Number Bases.

Page 1: Data Types and Representation CS French Chapter 6 + Chapter 7 – Number Bases.

Data Types and RepresentationData Types and Representation

CS FrenchCS French

Chapter 6Chapter 6

+ Chapter 7 – Number Bases+ Chapter 7 – Number Bases

Page 2: Data Types and Representation CS French Chapter 6 + Chapter 7 – Number Bases.

Data ProcessingData Processing

DataData

eg ESB meter eg ESB meter readingsreadings

Maintained Dataeg names, addresses, account numbers, last

meter reading, amount already owed.

Processingby

Computer

INFORMATION

eg bills

Page 3: Data Types and Representation CS French Chapter 6 + Chapter 7 – Number Bases.

Scientific ProcessingScientific Processing

DataData eg current eg current

weather weather conditionsconditions

Processingby

ComputerLarge amount of

calculations of changes over small distances

and time periods.

INFORMATIONdescription of tomorrow’s

weather

Page 4: Data Types and Representation CS French Chapter 6 + Chapter 7 – Number Bases.

Basic Data TypesBasic Data Types Data is represented by the character setData is represented by the character set

Р0..9,a...z,A....Z, !ӣ$%.()~ etc0..9,a...z,A....Z, !ӣ$%.()~ etc Character TypesCharacter Types

– Numeric 0...9Numeric 0...9– Alphabetic (upper and lower case)Alphabetic (upper and lower case)– SpecialSpecial

Data TypesData Types– NumericNumeric

» signed/unsigned integers, real, fised / floating pointsigned/unsigned integers, real, fised / floating point

– AlphabeticAlphabetic– AlphanumericAlphanumeric

Page 5: Data Types and Representation CS French Chapter 6 + Chapter 7 – Number Bases.

Data Representation for Data Representation for Computer DevicesComputer Devices

Punched Paper tape (obsolete)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.

Page 6: Data Types and Representation CS French Chapter 6 + Chapter 7 – Number Bases.

Binary DevicesBinary Devices Punched tape can be replaced by any device that contains items that can be set to any Punched tape can be replaced by any device that contains items that can be set to any

one of two positions.one of two positions. Magnetic tapeMagnetic tape/disc /disc

– spots can be magnetised one direction NORTH or the other SOUTHspots can be magnetised one direction NORTH or the other SOUTH TransistorsTransistors

– Electronic switches that can be ON or OFFElectronic switches that can be ON or OFF CCharged cellsharged cells

– An electronic device that can have a NEGATIVE or POSITIVE chargeAn electronic device that can have a NEGATIVE or POSITIVE charge RReflective surface (CD)eflective surface (CD)

– Spots on the disc may REFLECT a thin laser light or NOT REFLECT itSpots 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 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.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)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 One item in the device is required to store a bit (a switch, a hole, a magnetic spot, a reflective spot etc.)etc.)

Page 7: Data Types and Representation CS French Chapter 6 + Chapter 7 – Number Bases.

Some ASCII CodesSome ASCII CodesBinary CodeBinary Code

0010000000100000

0010000100100001

0011011000110110

0011011100110111

0100000101000001

0100001001000010

0110000101100001

ASCII CharacterASCII Character

SPACESPACE

!!

66

77

AA

BB

aa

How many possible characters can be represented with 8 bits?

Page 8: Data Types and Representation CS French Chapter 6 + Chapter 7 – Number Bases.

Data TransmissionData Transmission

1v 5v

5 0 1

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 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 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.translated into characters using the ASCII table.

Why is the 0 volt position in the switch necessary?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 If you are transmitting 2 ones or zeros consecutively you can momentarily switch the light off to distinguish

between them. 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 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.and ‘no signal’ being transmitted.

Page 9: Data Types and Representation CS French Chapter 6 + Chapter 7 – Number Bases.

Pulse Train for ASCII ‘K’Pulse Train for ASCII ‘K’

Time

Voltage

1

5

0 1 0 0 1 0 1 1

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.

Page 10: Data Types and Representation CS French Chapter 6 + Chapter 7 – Number Bases.

ParityParity (not required for 1(not required for 1stst year course) year course)

An extra bit is added to each code if required in An extra bit is added to each code if required in order to ensure there is an ODD number of 1’s in order to ensure there is an ODD number of 1’s in the code.(odd parity)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

Page 11: Data Types and Representation CS French Chapter 6 + Chapter 7 – Number Bases.

Bit Mapped ImagesBit Mapped Images

Page 12: Data Types and Representation CS French Chapter 6 + Chapter 7 – Number Bases.

Digitised SoundDigitised 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.

Page 13: Data Types and Representation CS French Chapter 6 + Chapter 7 – Number Bases.

Chapter 7: Number BasesChapter 7: Number Bases

1 1 1 12 2 2 103 3 3 114 4 4 1005 5 5 1016 6 6 1107 7 7 1118 10 8 10009 11 9 100110 12 A 101011 13 B 101112 14 C 110013 15 D 110114 16 E 111015 17 F 111116 20 10 1000017 21 11 1000118 22 12 1001019 23 13 1001120 24 14 1010021 25 15 10101

Decimal Octal Hexadecimal Binary Think about how you count!

It is easier to convert from binary to octal or hexadecimal than to decimal!

Page 14: Data Types and Representation CS French Chapter 6 + Chapter 7 – Number Bases.

ConversionsConversions

Binary to decimal: 1 1 0 1

ones

twos

fours

eights

1x1 = 10x2 = 01x4 = 41x8 = 8Total 13

Decimal to binary: 2 21 2 10 1 2 5 0 2 2 1 2 1 0 2 0 1

leftovers

21 = 10101