0% found this document useful (0 votes)
34 views46 pages

CH#1 Information Representation

The document discusses different number systems including binary, decimal, and hexadecimal numbers. It also covers how to convert between these number systems and perform calculations with binary numbers. Additional topics covered include signed integers, overflow, binary-coded decimal, ASCII, Unicode, and sound and image file formats.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views46 pages

CH#1 Information Representation

The document discusses different number systems including binary, decimal, and hexadecimal numbers. It also covers how to convert between these number systems and perform calculations with binary numbers. Additional topics covered include signed integers, overflow, binary-coded decimal, ASCII, Unicode, and sound and image file formats.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 46

Chapter # 1

Number systems
 Denary numbers:
 which are also known as decimal numbers are written
using one of the symbols 0,1,2,3,4,5,6,7,8,9 for each
denary digit

 Denary numbers:
 The binary number system is base-2. Each binary digit is
written with either of the symbols 0 and 1.
 A binary digit is referred to as a bit.
 Binary codes are most often based on the use of one or more
groups of eight bits. A group of eight bits is called a byte.
Number systems
 Hexadecimal numbers:
 These are base-16 numbers where each hexadecimal
digit is represented by one of the following symbols:
0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F.

 A nibble can be represented by one hexadecimal digit.


 This means that each byte of binary code can be written
as two hexadecimal digits.
 a binary code must not include blanks; all positions in
the byte must have either a 0 or a 1.
Converting between binary and denary numbers
 To carry out the conversion you start at the most
significant bit and successively multiply by two and
add the result to the next digit.
 to convert the binary number 11001 to the denary
number 25:

 to convert the binary number 1001110 to the denary


number.
Converting between binary and denary numbers
 to convert a denary value to its binary equivalent is the
procedure of successive division by two with the remainder
written down at each stage.
 The converted number is then given as the set of
remainders in reverse order.
 conversion of denary 246 to binary
BACK
Conversions for hexadecimal numbers
 To convert a hexadecimal number to binary, each digit is
treated separately and converted into a 4-bit binary
equivalent, remembering that F converts to 1111, E converts
to 1110 and so on.
 To convert a binary number to hexadecimal you start with
the four least significant bits and convert them to one
hexadecimal digit.
 You then proceed upwards towards the most significant
bit, successively taking groupings of four bits and
converting each grouping to the corresponding
hexadecimal digit.
 Convert each of the denary numbers 96, 215 and 374 into
hexadecimal numbers.
 Convert each of the hexadecimal numbers B4, FF and 3A2C to
denary numbers.
 If a calculation is to be performed with values quoted with
diff erent magnitude factors there must first be conversions
to ensure all values have the same magnitude factor.
 if you needed to know how many files of size 2.4 MiB could
be stored on a 4 GiB memory stick there should be a
conversion of the GiB value to the corresponding MiB
value.
Representations of signed integers

 TASK 1 Take the two’s complement of the binary code


for –7 and show that you get the code for +7.
 TASK 2 Convert the two’s complement number 1011 to
the denary equivalent. Then do the same for 111011 and
convince yourself that you get the same value.
Binary arithmetic
 The rules for the addition of binary digits are:
 0+0=0
 0+1=1
 1 + 1 = 0 with a carry of 1
 1 + 1 + 0 = 0 with a carry of 1
 1 + 1 + 1 = 1 with a carry of 1
 the addition of the binary equivalent of denary 14 to the
binary equivalent of denary 11 can be examined.
Binary arithmetic
 The rules for the subtraction of binary digits are:
 0–0=0
 0 – 1 = 1 after a borrow
 1–0=1
 1–1=0
 the subtraction of the binary equivalent of denary 11 from
the binary equivalent of denary 14 can be examined
 Overflow: a condition when the result of a calculation is
too large to fit into the number of bits defined for storage.

 The overflow means that the answer has a leading 1, which causes a
computer system to interpret the answer as a negative number.

 This time there has been a carry when the most significant bits
were added and the result obtained is a positive number.
Binary-coded decimal (BCD) system
 The binary-coded decimal (BCD) system uses a 4-bit code
to represent each denary digit:
Uses of BCD
 The most obvious use of BCD is in the representation of digits on
a calculator or clock display.

 Each denary digit will have a BCD equivalent value which makes
it easy to convert from computer output to denary display.
ASCII codes
 The standard ASCII code character set consists of 7-bit
codes (0 to 127 denary or 0 to 7F in hexadecimal);
 this represents the letters, numbers and characters
found on a standard keyboard together with 32 control
codes (which use up codes 0 to 31 (denary) or 0 to 19
(hexadecimal)).
 Extended ASCII uses 8-bit codes (128 to 255 in
denary or 80 to FF in hex).
 This allows for non-English characters and for drawing
characters to be included.
Unicodes
 One coding system is called Unicode.
 Unicode allows characters in a code form to represent all
languages of the world,
 thus supporting many operating systems, search engines and
internet browsers used globally.
 There is overlap with standard ASCII code, since the first 128
(English) characters are the same, but Unicode can support
several thousand different characters in total.
 create a universal standard that covered all languages and all
writing systems
 » produce a more efficient coding system than ASCII
 » adopt uniform encoding where each character is encoded as 16-bit
or 32-bit code
 » create unambiguous encoding where each 16-bit or 32-bit value
always represents the same character
 » reserve part of the code for private use to enable a user to assign
codes for their own characters and symbols (useful for Chinese and
Japanese character sets).
Unicode
Sample Questions
Multimedia
 Images can be stored in a computer in two common
formats:
 bit-map image
 vector graphic
 Bit-map images
 Bit-map images are made up of pixels (picture
elements);
 the image is stored in a two-dimensional matrix of
pixels.
 Pixels can take different shapes, such as
 » at least 8bits (1 byte) per pixel are needed to code a coloured
image
 » true colour requires 3bytes per pixel (24bits), which gives
more than one million colours
 » the number of bits used to represent a pixel is called the
colour depth
 bit depth is best defined as the number of bits used to store
each of the red, green and blue primary colours in the RGB
colour scheme.
 A colour depth of 8 bits per pixel provides 256 different colours.
 A bit depth of 8 bits per primary colour provides 256 × 256 × 256
= 16 777 216 different colours.
 Image resolution: the number of pixels in the bitmap file
defined as the product of the width and the height values
 Screen resolution: the product of width and height values for
the number of pixels that the screen can display
 pixel density: the number of pixels per square inch
how pixel density can be calculated
for a given screen.
 Imagine we are using an Apple iPhone 8 which has 5.5-
inch screen size and screen resolution of 1920 pixels ×
1080 pixels:
1. add together the squares of the resolution size ((1920 2
+ 1080 2) = (3 686 400 + 16 640) = 4 852800)
2. find the square root =
3. divide by screen size (2202.907 ÷ 5.5 = 401)
 This gives us the pixel density of 401 pixels per square
inch (ppi)
Calculating bit-map image file sizes
 As an example, consider that a bitmap graphic is needed to
fill a laptop screen where the resolution is 1366 by 768. If
we want colour depth of 24 then the number of bits we
need is:
File Header
 when saving a bit-map image, it is important to
include a file header;
 this will contain items such as
 file type (.bmp or .jpeg)
 file size
 image resolution
 bit depth (usually 1, 8, 16, 24 or 32)
 any type of data compression employed and so on.
Vector graphics
 Vector graphics are images that use 2D points to describe lines
and curves and their properties that are grouped to form
geometric shapes.
 Vector graphics can be designed using computer aided design
(CAD) software or using an application which uses a drawing
canvas on the screen.
 A vector graphic will contain a drawing list (included in a file
header) that is made up of
 » the command used for each object that makes up the graphic
image
 » the attributes that define the properties that make up each object
 » the relative position of each object will also need to be included
 » the dimensions of each object are not defined, but the relative
positions of objects to each other in the final graphic need to be
defined; this means that scaling up the vector graphic image will
result in no loss of quality.
Comparison between vector graphics and bit-map images
Sound files
 Sound is an analogue value; this needs to be digitised in order to
store sound in a computer.
 This is done using an analogue to digital converter (ADC).
 If the sound is to be used as a music file, it is often filtered first
to remove higher frequencies and lower frequencies which are
outside the range of human hearing.
 To convert the analogue data to digital, the sound waves are
sampled at a given time rate.

 using a range of 0 to 127 gives a much more accurate


representation of the sound sample than using a range of, for
example, 0 to 10).
 This is known as the sampling resolution (also known as the
bit depth).
 Sampling rate is the number of sound samples taken per
second.
 The higher the sampling rate and/or sampling resolution,
the greater the file size.
 a 16-bit sampling resolution is used when recording CDs to
give better sound quality.
 Using a higher sampling rate or larger resolution will result
in a more faithful representation of the original sound
source.
• Can resize it without pixilation
• Image is redrawn/recalculated with each adjustment
• Smaller file size
• Storing points/equations/commands etc., not individual
pixels
File compression
 The two most common forms of file compression are
 lossless file compression
 lossy file compression.
 Lossless file compression
 all the data from the original file can be reconstructed
when the file is uncompressed again.
 This is particularly important for files where loss of any
data would be disastrous.
 Lossy file compression
 the file compression algorithm eliminates unnecessary
data (as with MP3 and JPEG formats, for example).
 MPEG-3 (MP3) uses technology known as audio
compression to convert music and other sounds into an
MP3 file format.
 Essentially, this compression technology will reduce the
size of a normal music file by about 90%.
 This is done using file compression algorithms that use
perceptual music shaping.
 Perceptual music shaping removes certain sounds.
 For example
 » frequencies that are outside the human hearing range
 » if two sounds are played at the same time, only the louder
one can be heard by the ear, so the softer sound is eliminated.
Run-length encoding (RLE)
 used to compress a number of different file formats.
 lossless/reversible file compression
 A repeating string is encoded into two values.
 The first value represents the number of identical data items
 The second value represents the code of the data item
 RLE is only effective where there is a long run of repeated units/bits.

 One issue occurs with a string such as ‘cdcdcdcdcd’, where compression


is not very effective.

 To cope with this we use a flag.


 A flag preceding data indicates that what follows are the number of
repeating units
 Introducing a flag (255 in this case) produces: 255 08 97 255 10 98 99 100
99 100 99 100 255 08 101
Using RLE with images
 Black and white images

 Coloured image
1

1 mark for correct method (colour code and number of


pixels)
1 mark for first 7 groups correct
1 mark for remainder correct

• 3B9 1A3 3B3 1A2 3B1 1A2 3B2


• 1A1 3B3 1A1 3B2 1A2 3B1 1A2 3B3 1A3 3B9

5
1 mark for purpose • Stores data about the file contents/image/metadata
Max 2 marks for examples of contents
• Confirmation that the file is a BMP // confirmation of file type
• File size
• Location / offset of image data within the file
• Dimensions of the image (in pixels) // image resolution
• Colour depth (bits per pixel, 1, 4, 8, 16, 24 or 32)
• Type of compression used (if any)
1 mark per bullet point to max 2 for description
• Instead of storing each repeated sequence of characters individually
• … the character is stored and the number of consecutive occurrences
1 mark for using relevant example e.g.
• instead of storing aaaa , store a4

1 mark per bullet point to max 2


• Repeated sequences of characters rarely occur in text files // Most characters
are used only once in any sequence
• The character code and the fact that it is stored once will both be stored, which
will use as much if not more space

You might also like