Chapter 1: Information Representation
Data Representation
The basis of any number system consists of:
o A base: the number of digits that a number system can use to represent numbers
o Place value for each digit: digits in certain positions have a specific value
Denary - Base 10 integer digits
Binary Systems - Base 2
o Possible bits (binary digits): 0 and 1
o All data and characters are represented in binary
128 64 32 16 8 4 2 1
0 0 0 0 0 0 0 0
E.g. 65 in binary is 0100001
Denary vs. Binary prefixes:
Denary Prefix factor value Binary Prefix factor value
kilo- (k) ×10^3 kibi- (Ki) ×2^10
mega- (M) ×10^6 mebi- (Mi) ×2^20
giga- (G) ×10^9 gebi- (Gi) ×2^30
tera- (T) ×10^12 tebi- (Ti) ×2^40
Binary Coded Decimal (BCD)
o Binary representation where each positive denary digit is represented by a sequence of
4 bits (nibble)
o Only certain digits are converted to BCD, because particular digits represent a digit
greater than 9.
o Ex. 429 in BCD:
Convert each digit to their binary equivalents
4 = 0100 | 2 = 0010 |9 = 1001
Concatenate the 3 nibbles (4-bit group) to produce BCD: 0100 0010 1001
Practical applications
o A string of digits on any electronic device displaying numbers (eg. Calculators)
o Accurately measuring decimal fractions
o Electronically coding denary numbers
Two’s Complement
o We can represent a negative number in binary by making the most significant bit (MSB)
a sign bit, which indicates whether the number is positive or negative.
o Converting negative denary into binary (ex. -42)
Find the binary equivalent of the denary number (ignoring the -ve sign) | 42 = 101010
Add extra 0 bits before the MSB, to format binary number to 8 bits | 00101010
Convert binary number to one’s complement (flip the bits) | 11010101
Convert binary number to two’s complement (add 1) |1010101 + 1 = 11010110
Converting binary two’s complement into denary (ex. 11010110)
o Flip all the bits | 00101001
o Add 1 | 00101010
o Convert binary to denary and put a –ve sign) | -42
Maximum positive number in 8 bits: 255
Maximum negative number in 8 bits: -128
Hexadecimal Systems - Base 16
o Possible digits: 0 to 9 and A to F, where A to F represent denary digits 10 to 15
o Practical applications:
Defining colours in HTML
Defining Media Access Control (MAC) addresses
Assembly languages and machine code
Debugging via memory dumps
o E.g. A5 in Denary = (16×10) + (1×5) = 165
o E.g. 65 in Hexadecimal = 65÷16=4 Remainder 1∴ = 41
Character Sets
o A character set generally includes upper & lower case letters, number digits,
punctuation marks and other characters.
o Character sets use different binary representations for each character via character
encoding
o Character Encoding Standards:
ASCII Extended ASCII Unicode
ASCII’s extension - Also Superset for ASCII & extended
Only English alphabets can be
includes most European ASCII - recognized by various
represented
languages’ alphabets global languages
Each character encoding takes ASCII extended to 8 bits, Greater range of characters, as
up 7 bits, hence 128 possible hence 256 possible it uses 2 or 4 bytes per
characters characters. character.
2 or 4 times more storage
Smaller storage space.
space per character.
Multimedia
Bitmap Images
o Data for a bitmapped image is encoded by assigning a solid colour to each pixel, i.e.,
through bit patterns.
o Bit patterns are generated by considering each row of the grid as a series of binary
colour codes which correspond to each pixel’s colour.
o These bit patterns are ‘mapped’ onto main memory
o Pixels: smallest picture element whose colour can be accurately represented by binary
Bitmap image also contains the File Header which has the metadata contents of
the bitmap file, including image size, number of colours, etc.
Image Resolution
o Pixel density which is measured by no. of pixels/cm
o If image resolution increases, then image is sharper/more detailed
Screen Resolution
o Number of pixels which can be viewed horizontally & vertically on the device’s screen
o Number of pixels = width × height
o E.g. 1680 × 1080 pixels
Colour depth: number of bits used to represent the colour of a single pixel
o An image with n bits has 2n colours per pixel
o E.g. 16-colour bitmap has 4 bits per pixel ∵ 24=1624=16
o Colour depth↑: colour quality↑ but file size↑
o File Size = Number of Pixels × colour depth
o Convert bits to bytes by dividing by 8 if necessary.
Applications: scanned images and general computer usage ∵ small file size and can be easily
manipulated.
Vector Graphics
o Made up of drawing objects
o Drawing objects: a mathematically defined construct (of shapes like rectangle, line,
circle, etc.)
o Drawing list: set of commands defining the vector
o Properties of each object are the basic geometric data which determine the shape and
appearance.
o Data is encoded using mathematical formulas to generate properties in order to draw
lines & curves to create the image
o If object is resized, properties are recalculated.
∴ Scalable without losing quality unlike bitmaps
Applications: company logos
Sound
o Analogue data is continuous electrical signals whereas digital data is discrete electrical
signals.
o Sound signals are vibrations through a medium. Hence are analogue in nature as there
can be an infinite amount of detail for sound.
o Analogue signals converted (encoded) to digital signals by sampling:
Sound wave’s amplitude (height) sampled at set time intervals
These samples (amplitudes) are encoded as a binary number sequence
This sequence provides a digital representation of the sound wave
Sampling Rate
o Number of samples taken per unit time
o Increasing the sampling rate increases accuracy of digitized sound wave representation
but increases the file size
Sampling Resolution
o Number of bits used to encode each sample
o Increasing sampling resolution increases accuracy of digitized sound wave but increases
the file size
Bit Rate: no. of bits for storing 1 second of sound
Bit Rate=Sampling Rate × Sampling Resolution
File Size=Bit Rate * Length of Sound
Compression
Compression is the process of reducing file size without a significant loss in quality which results
in
o Reducing the time needed to search for data.
o Faster transfer of compressed files, which uses less bandwidth than uncompressed files.
Lossless Compression
o Type of compression that allows original data to perfectly reconstructed from
compressed file when the file is opened by utilizing some form of replacement.
o E.g. bitmap (.bmp), vector graphic (.svg) and .png images, text file compression,
database records
o Run-length Encoding (RLE)
Form of lossless compression which is used for compressing text files and
bitmap images.
Reduces file size of a sequence of elements which has adjacent, identical
elements (characters in text file and pixels in bitmap images).
Repeating sequence of elements encoded in two values: run count and run
value.
o E.g. RLE of bitmap image:
We can represent the first row as a sequence of pixels: “W B B W W B B W” | W:
white and B: black
After applying RLE: “W 2B 2W 2B W”.
In ‘2B’ 2 is the run count and B is the run value, which represents a run of two
adjacent black pixels
Process is repeated for other rows.
Lossy Compression
o Type of compression which irreversibly eliminates unnecessary data
o File accuracy/quality lower than that of lossless but file size is lower (~10% of lossless).
o E.g. Sound files (.mp3), .jpeg images
o Sound files compression (.mp3) utilizes Perceptual Coding to remove certain parts of
sound that are less audible/discernible to human hearing.