objectives data representation binary number system binary coded decimal (bcd) boolean values...

12
Objectives Objectives Data Representation Binary number system Binary Coded Decimal (BCD) Boolean Values Analogue & Digital data Use of ASCII code Memory addressing

Upload: austen-shelton

Post on 29-Dec-2015

214 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Objectives Data Representation Binary number system Binary Coded Decimal (BCD) Boolean Values Analogue & Digital data Use of ASCII code Memory addressing

ObjectivesObjectives

Data RepresentationBinary number systemBinary Coded Decimal (BCD)Boolean ValuesAnalogue & Digital dataUse of ASCII codeMemory addressing

Page 2: Objectives Data Representation Binary number system Binary Coded Decimal (BCD) Boolean Values Analogue & Digital data Use of ASCII code Memory addressing

Data RepresentationData Representation Character coding schemes

ASCII, Unicode Unicode – International 16-bit coding system which can

represent 65536 different characters Binary number system Binary Coded Decimal (BCD)

each decimal digit has its own 4-bit binary code Boolean values

only True or False Digitised sound

MIDI Bit-mapped graphics

Page 3: Objectives Data Representation Binary number system Binary Coded Decimal (BCD) Boolean Values Analogue & Digital data Use of ASCII code Memory addressing

Number systemsNumber systems Denary system ‘134’ represents

one hundred, three tens and four ones. 100 10 1

1 3 4

= 100 + 30 + 4 = 134 Binary system 128 64 32 16 8 4 2 1 1 0 0 0 0 1 1 0

= 128 + 4 + 2 = 134

Page 4: Objectives Data Representation Binary number system Binary Coded Decimal (BCD) Boolean Values Analogue & Digital data Use of ASCII code Memory addressing

Binary number systemBinary number system Numbers can be represented in a computer in a number of different

ways, e.g. 25 in ASCII would be: 0011 0010 0011 0101 Alternatively in pure binary draw a table of powers of 2. Then find the

largest power of 2<=25 (16). Subtract 16 from 25 and repeat Value 128 64 32 16 8 4 2 1

0 0 0 1 1 0 0 1 16 + 8 + 1 = 25 To translate from binary to decimal perform same process backwards Value 128 64 32 16 8 4 2 1

0 1 0 0 0 1 0 1 64 + 4 + 1 = 69

Page 5: Objectives Data Representation Binary number system Binary Coded Decimal (BCD) Boolean Values Analogue & Digital data Use of ASCII code Memory addressing

Binary Coded Decimal (BCD)Binary Coded Decimal (BCD) In the BCD system each decimal represented with own

4-bit binary code.

3765 is coded as 0011 0111 0110 0101

Decimal Binary Decimal Binary

0 0000 5 0101

1 0001 6 0110

2 0010 7 0111

3 0011 8 1000

4 0100 9 1001

Page 6: Objectives Data Representation Binary number system Binary Coded Decimal (BCD) Boolean Values Analogue & Digital data Use of ASCII code Memory addressing

Advantages & disadvantages of BCDAdvantages & disadvantages of BCD Advantage - ease of conversion from BCD to decimal and vice versa. E.g. when binary numbers have to be decoded for a calculator display, a

number held in BCD has simply to have each bit converted into decimal. Another advantage - BCD does not “round” numbers - uses as many bits

as reqd. Disadvantage - calculations with BCD numbers are more complex. E.g

adding 1 and 19 0000 0001 0001 1001 0001 1010 The first digit 1, is wrong and 1010 is an invalid code Error occurs because only 10 out of 16 combinations of 4 bits used.

Whenever sum greater than 9, 6 has to be added to result in order to skip over codes

0001 1010 0110 0010 0000 i.e. 20 in BCD which is correct

Page 7: Objectives Data Representation Binary number system Binary Coded Decimal (BCD) Boolean Values Analogue & Digital data Use of ASCII code Memory addressing

Boolean ValuesBoolean Values

A Boolean variable can only have one of two values, true or false

Represented by a 1 or a 0Useful to be able to use a binary bit to show

if something is true or false, e.g:– To show whether a disk drive is connected– To show if the ‘break’ key is pressed’

Single bits used in this way are called Flags

Page 8: Objectives Data Representation Binary number system Binary Coded Decimal (BCD) Boolean Values Analogue & Digital data Use of ASCII code Memory addressing

Analogue & Digital dataAnalogue & Digital data

Almost everything in the world can be described or represented in one of two forms: analogue or digital.

Principal feature of analogue representations is that they are continuous.

Digital representations consist of values measured at discrete intervals. Digital watches are digital because they go from one value to the next

without displaying all intermediate values. Display a finite number of times of the day.

In contrast, watches with hands are analogue, because hands move continuously around the clock face.

Page 9: Objectives Data Representation Binary number system Binary Coded Decimal (BCD) Boolean Values Analogue & Digital data Use of ASCII code Memory addressing

Digitised soundDigitised sound

Sound can be input via microphone, CD or electronic keyboard with MIDI (Musical Interchange Digital Interface)

Since sound waves are continuously variable or Analogue – an analogue to digital converter is needed to transform analogue input into to a digital form, i.e. a binary pattern

Undesirable sounds such as scratches can be edited Sound in analogue form can be represented by wave forms

– Height of wave forms sampled at regular time intervals– Height may be represented by, say, a 16-bit code which is format

used for standard audio, 8-bit slightly better than normal AM radio.– More frequently samples taken – better the sound quality

Page 10: Objectives Data Representation Binary number system Binary Coded Decimal (BCD) Boolean Values Analogue & Digital data Use of ASCII code Memory addressing

The ASCII codeThe ASCII code

Binary digit (1 or 0) known as a ‘bit’, short for BInary digiT bits generally grouped together in 8-bit bytes a byte can hold 28 combinations of 0s and 1s This means that, for example, 256 different

characters can be represented.

Page 11: Objectives Data Representation Binary number system Binary Coded Decimal (BCD) Boolean Values Analogue & Digital data Use of ASCII code Memory addressing

Sample ASCII codesSample ASCII codesCharac ASCII Charac ASCII Charac ASCII Charac ASCII

A 1000001 K 1001011 U 1010101 a 1100001

B 1000010 L 1001100 V 1010110 b 1100010

C 1000011 M 1001101 W 1010111 c 1100011

D 1000100 N 1001110 X 1011000 d 1100100

E 1000101 O 1001111 Y 1011001 e 1100101

F 1000110 P 1010000 Z 1011010 f 1100110

G 1000111 Q 1010001 [ 1011011 g 1100111

H 1001000 R 1010010 \ 1011100 h 1101000

I 1001001 S 1010011 ] 1011101 i 1101001

J 1001010 T 1010100 ^ 1011110 j 1101010

Page 12: Objectives Data Representation Binary number system Binary Coded Decimal (BCD) Boolean Values Analogue & Digital data Use of ASCII code Memory addressing

Memory addressingMemory addressing The memory of a computer can be thought of as a series of

boxes, each containing 8 bits (1 byte), and each with its own unique address, counting from zero upwards.

Memory capacity is measured in thousand byte units Kb, Mb, Gb.

These are all powers of 2 thus although often thought of as being 1000 bytes, actually 1024 bytes.

210 bytes = 1024 = 1Kb 220 bytes = 1024 x 1024 = 1Mb 230 bytes = 1024 x 1024 x 1024 = 1Gb