Objectives Data Representation Binary number system Binary Coded Decimal (BCD) Boolean Values Analogue & Digital data Use of ASCII code Memory addressing
Data Representation Character coding schemes ASCII, Unicode Unicode – International 16-bit coding system which can represent 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
Number systems Denary system ‘134’ represents one hundred, three tens and four ones = = 134 Binary system = = 134
Binary number system Numbers can be represented in a computer in a number of different ways, e.g. 25 in ASCII would be: 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 = 25 To translate from binary to decimal perform same process backwards Value = 69
Binary Coded Decimal (BCD) In the BCD system each decimal represented with own 4-bit binary code is coded as DecimalBinaryDecimalBinary
Advantages & 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 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 i.e. 20 in BCD which is correct
Boolean Values A Boolean variable can only have one of two values, true or false Represented by a 1 or a 0 Useful 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
Analogue & 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.
Digitised 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
The 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 2 8 combinations of 0s and 1s This means that, for example, 256 different characters can be represented.
Sample ASCII codes Charac ASCIICharac ASCIICharac ASCIICharac ASCII A K U a B L V b C M W c D N X d E O Y e F P Z f G Q [ g H R \ h I S ] i J T ^ j
Memory 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 bytes = 1024 = 1Kb 2 20 bytes = 1024 x 1024 = 1Mb 2 30 bytes = 1024 x 1024 x 1024 = 1Gb