[go: up one dir, main page]

0% found this document useful (0 votes)
14 views21 pages

Liberty Computer Science Notes-1

science
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views21 pages

Liberty Computer Science Notes-1

science
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 21

Data Representation

Number Systems
The Denary, Binary & Hexadecimal Number Systems
The Denary Number System
 Denary is a number system that is made up of 10 digits (0-9)
 Denary is referred to as a base-10 number system
 Each digit has a weight factor of 10 raised to a power, the rightmost digit is 1s (100), the
next digit to the left 10s (101) and so on
 Humans use the denary system for counting, measuring and performing math calculations
The Binary Number System
 Binary is a number system that is made up of two digits (1 and 0)
 Binary is referred to as a base-2 number system
 Each digit has a weight factor of 2 raised to a power, the rightmost digit is 1s (20), the
next digit to the left 2s (21) and so on
 Each time a new digit is added, the column value is multiplied by 2
 Using combinations of the 2 digits we can represent any number
 Data is processed in a computer using logic gates that only have two states(1/0)
 This means each digit can represent a different state (1 = on, 0 = off)
 All data must be converted to binary before a computer can understand and process it
 Converting data to binary allows computers to process it at an incredible speed, perform
complex calculations and store vast amounts of data efficiently

Denary to Binary Conversions


Examples
Convert the following Denary Numbers to Binary
i. 00110011
ii. 01111111
iii. 10011001
Binary to Denary Conversions
examples
i. 255
ii. 127
iii. 4095

The hexadecimal Number System


 Hexadecimal is a number system that is made up of 16 digits, 10 numbers (0-9) and 6
letters (A-F)

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14

0 1 2 3 4 5 6 7 8 9 A B C D E

 Hexadecimal is referred to as a base-16 number system


 Each digit has a weight factor of 16 raised to a power, the rightmost digit is 1s (16^0),
the next digit to the left 16s (16^1)
Binary to Hexadecimal Conversions
i. 11000011
ii. 11110111
Hexadecimal to Denary Conversions
i. A00
ii. 40E
iii. BA6

Why Hexadecimal is Beneficial


1. Shorter Representation than Binary
o Binary numbers can become very long (e.g., 1101011010110111).

o The same value in hex is much shorter (e.g., D6B7).

o Each hex digit represents 4 binary digits (bits), making conversions


straightforward.
2. Easier for Humans to Read and Memorize
o Hex is more compact than binary and easier to interpret than long strings of 0s
and 1s.
o Example:

 Binary: 1111 0000 1010 0110


 Hex: F0A6 (much simpler to write and remember)
3. Direct Mapping to Binary
o Since 16 is 2424, hex aligns perfectly with bytes (8 bits = 2 hex digits).

o Example:

 Byte: 1010 1101 → AD in hex.


4. Useful for Debugging & Low-Level Programming
o Memory addresses, machine code, and binary data are often displayed in hex for
clarity.
o Example: A memory address like 0x7FFEF04A is easier to work with than its
binary equivalent.
Areas in Computer Science Where Hexadecimal is Used
1. Memory Addressing
o Hexadecimal is used to represent memory addresses (e.g., 0xFFFF0000 in
assembly language).
2. Color Representation (Web & Graphics)
o Colors in HTML/CSS are often written in hex (e.g., #FF5733 for Red=FF,
Green=57, Blue=33).
3. Machine Code & Assembly Language
o Hexadecimal is used to represent operation codes and binary instructions
compactly.
4. Networking & Data Packets
o MAC addresses are written in hex (e.g., 00:1A:2B:3C:4D:5E).

5. File Formats & Binary Data


o Hexadecimal editors display binary files in hexadecimal for easier analysis.
6. Debugging & Reverse Engineering
o Tools like debuggers and disassemblers show data in Hexadecimal for readability.

7. Embedded Systems & Hardware Programming


o Microcontroller registers and firmware often use hex notation.

Addition of 8-bit binary numbers


 8 bit binary number representations is when binary numbers are expressed as 8 figures
e.g. 12310 = 11110112
but in 8 bit representation, it will be written as 011110112
 Zeros are added at the leftmost side to make the number 8 bit.
 8 bit binary numbers are in the Range: 00000000 (0) to 11111111 (255) for positive
numbers (unsigned integers).

1. 11001100 (204)
+ 00110011 (51)
_______________
11111111 (255)

2. 11111111 (255)
+ 00000001 (1)
__________
100000000 (256) Overflow 9bit result

 When the addition results in a bit length greater that 8 or when the total exceeds the
denary 0-255 range, it is known as an overflow
Why Overflow Occurs
1. Fixed Bit-Length Limitation
o An 8-bit system can only represent numbers from 0 to 255.

o If the sum exceeds 255, the extra bit cannot be stored, causing wrap-around.

2. Carry Out of Most Significant Bit (MSB)


o Overflow is detected when addition produces a carry beyond the 8th bit.

- In programming, overflow can cause bugs or program crushes (e.g., a game score resetting
to 0 after reaching 255).

Binary Shifts
What is a logical binary shift?
 A logical binary shift is how a computer system performs basic multiplication and
division on non-negative values (0 and positive numbers)
 Binary digits are moved left or right a set number of times
 A left shift multiplies a binary number by 2 (x2)
 A right shift divides a binary number by 2 (/2)
 A shift can move more than one place at a time, the principle remains the same
 A left shift of 2 places would multiply the original binary number by 4 (x4)
How do you perform a logical left shift of 1?

128 64 32 16 8 4 2 1

0 0 1 0 1 0 0 0

 Here is the binary representation of the denary number 40


 To perform a left logical binary shift of 1, we move each bit 1 place to the left
 The digit in the 128 column (MSB) will move left causing an overflow error
 The 1 column becomes empty so is filled with a 0

128 64 32 16 8 4 2 1

0 1 0 1 0 0 0 = 40

0 1 0 1 0 0 0 0 = 80

 The original binary representation of denary 40 (32+8) was multiplied by 2 and


became 80 (64+16)
How do you perform a logical left shift of 2?
 Here is the binary representation of the denary number 28

128 64 32 16 8 4 2
0 0 0 1 1 1 0

 To perform a left binary shift of 2, we move each bit 2 places to the left
 The digit in the 128 (MSB) and 64 column will move left causing an overflow error
 The 1 and 2 column become empty so are filled with a 0

128 64 32 16 8 4 2 1

0 1 1 1 0 0 = 28

0 1 1 1 0 0 0 0 = 112

 The original binary representation of denary 28 (16+8+4) was multiplied by 4 and


became 112 (64+32+16)
Examiner Tips and Tricks
Your textbook might show shifts with longer binary values—but in IGCSE exams, you’ll only
ever be asked about 8-bit unsigned integers. That’s why all our examples are capped at 8 bits.
How do you perform a logical right shift of 1?
 Here is the binary representation of the denary number 40

128 64 32 16 8 4 2

0 0 1 0 1 0 0

 To perform a right binary shift of 1, we move each bit 1 place to the right
 The digit in the 1 column (LSB) will move right causing an underflow error
 The 128 column becomes empty so is filled with a 0

128 64 32 16 8 4 2 1

0 0 1 0 1 0 0 = 40

0 0 0 1 0 1 0 0 = 20

 The original binary representation of denary 40 (32+8) was divided by 2 and


became 20 (16+4)
How do you perform a logical right shift of 2?
 Here is the binary representation of the denary number 200
128 64 32 16 8 4 2

1 1 0 0 1 0 0

 To perform a right binary shift of 2, we move each bit 2 places to the right
 The digits in the 1 (LSB) and 2 columns will move right causing an underflow error
 The 128 and 64 columns become empty so are filled with a 0

128 64 32 16 8 4 2 1

1 1 0 0 1 0 = 200

0 0 1 1 0 0 1 0 = 50

 The original binary representation of denary 200 (128+64+8) was divided by 4 and
became 50 (32+16+2)

Two’s complement number system


Positive Denary and Binary Numbers

- It is used to represent negative denary numbers in 8 bit binary notation


- In two’s compliment, the Left Most Bit (LMB) is changed to a negative value.

-128 64 32 16 8 4 2 1

- This means the range of numbers is -128 (10000000) to 127 (01111111)

Example 1.
Convert 38 to twos compliment

-128 64 32 16 8 4 2 1

0 0 1 0 0 1 1 0

Example 2
Convert 125 to twos compliment

-128 64 32 16 8 4 2 1

0 1 1 1 1 1 0 0
Negative Binary & Denary Numbers
Two’s Compliment to Denary

1. Example Convert 100100111 twos compliment to denary

-128 64 32 16 8 4 2 1

1 0 0 1 0 0 1 1

:- = -128 + 16 + 2+ 1 = -109 z

2.Example Convert 11110011 twos compliment to denary

-128 64 32 16 8 4 2 1

1 1 1 1 0 0 1 1

:- = -128 + 64+ 32+ 16+ +2+1 = -13

Negative Denary Two’s Compliment


Convert – 13 to twos Compliment
Step 1: Convert to 8 bit Binary : 00001101
Step 2 Invert Bits 11110010
Add 1 + 1
11110011

Convert –109 to twos Compliment


Step 1: Convert to 8 bit Binary : 01101101
Step 2 Invert Bits 10010010
Add 1 + 1
10010011
Text Sound And Images
Character Sets
What is a character set?
 A character set is all the characters and symbols that can
be represented by a computer system
 Each character is given a unique binary code
 Character sets are ordered logically, the code for ‘B’ is one more than the
code for ‘A’
 A character set provides a standard for computers to communicate and
send/receive information
 Without a character set, one system might interpret 01000001 differently
from another
 The number of characters that can be represented is determined by
the number of bits used by the character set
 Two common character sets are:
o American Standard Code for Information Interchange (ASCII)
o Universal Character Encoding (UNICODE)
ASCII
What is ASCII?
 ASCII is a character set and was an accepted standard for information
interchange
 ASCII uses 7 bits, providing 27 unique codes (128) or a maximum of 128
characters it can represent
 ASCII only represents basic characters needed for English, limiting its use
for other languages
Extended ASCII
 Extended ASCII uses 8 bits, providing 256 unique codes (28 = 256) or a
maximum of 256 characters it can represent
 Extended ASCII provides essential characters such as mathematical
operators and more recent symbols such as ©
Limitations of ASCII & extended ASCII
 ASCII has a limited number of characters which means it can only represent
the English alphabet, numbers and some special characters
o A, B, C, ………, Z
o a, b, c ,.............,z
o 0, 1, 2,........, 9
o !, @, #, …..
 ASCII cannot represent characters from languages other than English
 ASCII does not include modern symbols or emojis common in today's
digital communication

UNICODE
What is UNICODE?
 UNICODE is a character set and was created as a solution to the limitations
of ASCII
 UNICODE uses a minimum of 16 bits, providing 216 unique codes (65,536)
or a minimum of 65,536 characters it can represent
 UNICODE can represent characters from all the major languages around
the world
Examiner Tips and Tricks
Exam questions often ask you to compare ASCII & UNICODE, for example
the number of bits, number of characters and what they store
ASCII vs UNICODE
ASCII UNICODE
Number of bits 7-bits 16-bits
Number of
128 characters 65,536 characters
characters
Used to represent characters Used to represent characters
Uses
in the English language. across the world.
It can represent more
characters than ASCII.
It uses a lot less storage It can support all common
Benefits
space than UNICODE. characters across the world.
It can represent special
characters such as emoji's.
It can only represent 128
characters. It uses a lot more storage
Drawbacks
It cannot store special space than ASCII.
characters such as emoji's.
Worked Example
The computer stores text using the ASCII character set.

Part of the ASCII character set is shown:


Character ASCII Denary Code
E 69
F 70
G 71
H 72
(a)
Identify the character that will be represented by the ASCII denary code
76 [1]
(b)
Identify a second character set [1]
Answers
(a) L (must be a capital)
(b) UNICODE

How Sound is Sampled & Stored


How is sound sampled & stored?
 Measurements of the original sound wave are captured and stored as
binary on secondary storage
 Sound waves begin as analogue and for a computer system to understand
them they must be converted into a digital form
 This process is called Analogue to Digital conversion (A2D)
 The process begins by measuring the amplitude of the analogue sound
wave at a point in time, called samples
 Each measurement (sample) generates a value which can be represented in
binary and stored
 Using the samples, a computer is able to create a digital version of the
original analogue wave
 The digital wave is stored on secondary storage and can be played back at
any time by reversing the process
 In this example, the grey line represents the digital wave that has been
created by taking samples of the original analogue wave
 In order for the digital wave to look more like the analogue wave the sample
rate and bit depth can be changed
Sample Rate & Sample Resolution
What is sample rate?
 Sample rate is the amount of samples taken per second of the analogue
wave
 Samples are taken each second for the duration of the sound
 The sample rate is measured in Hertz (Hz)
 1 Hertz is equal to 1 sample of the sound wave

In this example you can see that the higher the sample rate, the closer to the
original sound wave the digital version looks
 The sampling rate of a typical audio CD is 44.1kHz (44,100 Hertz or 44,100
samples per second)
 Using the graphic above helps to answer the question, “Why does telephone
hold music sound so bad?”
What is sample resolution?
 Sample resolution is the number of bits stored per sample of sound
 Sample resolution is closely related to the colour depth of a bitmap image,
they measure the same thing in different contexts
Bitmap Images
What is a bitmap?
 A bitmap image is made up of squares called pixels
 A pixel is the smallest element of a bitmap image
 Each pixel is stored as a binary code
 Binary codes are unique to the colour in each pixel
 A typical example of a bitmap image is a photograph
 The more colours and more detail in the image, the higher the quality of the
image and the more binary that needs to be stored
Resolution & Colour Depth
What is resolution?
 Resolution is the total amount of pixels that make up a bitmap image
 The resolution is calculated by multiplying the height and width of the
image (in pixels)
 In general, the higher the resolution the more detail in the image (higher
quality)
 Resolution can also refer to the total amount of pixels horizontally in a
display, such as:
o Computer monitors - 1440p means 1440 pixels horizontally
compared to 4K which is 3840 pixels (roughly 4 thousand)
o TVs - HD (high definition) channels have a resolution of 1080p, 1080
pixels horizontally compared to newer UHD (ultra high definition)
channels with 3840 pixels (4K)
o YouTube - The quality button allows a user to change the video
playback resolution from 144p (144 pixels horizontally) up to 4K
What is colour depth?
 Colour depth is the number of bits stored per pixel in a bitmap image
 The colour depth is dependent on the number of colours needed in the image
 In general, the higher the colour depth the more detail in the
image (higher quality)
 In a black & white image the colour depth would be 1, meaning 1 bit is
enough to create a unique binary code for each colour in the image (1=white,
0=black)

 In an image with a colour depth of 2, you would have 00, 01, 10 & 11
available binary codes, so 4 colours
 As colour depth increases, so does the amount of colours available in an
image
 The amount of colours can be calculated as 2n (n = colour depth)
Colour Depth Amount of Colours
1 bit 2 (B&W)
2 bit 4
4 bit 16
8 bit 256
24 bit 16,777,216 (True Colour)
What is the impact of resolution and colour depth?
 As the resolution and/or colour depth increases, the bigger the size of the
file becomes on secondary storage
 The higher the resolution, the more pixels are in the image, the more bits
are stored
 The higher the colour depth, the more bits per pixel are stored
 Striking a balance between quality and file size is always a consideration
Worked Example
1. Define the term Pixel [1]
2. If an image has a colour depth of 2 bits, how many colours can the image
represent? [1]
3. Describe the impact of changing an images resolution from 500x500 to
1000x1000 [2]
Answers
1. The smallest element of a bitmap image (1 square)
2. 4
3. The image quality would be higher [1] the file size would be larger [1]

Units of Data Storage


What are units of data storage?
 A unit of data is a term given to describe different amounts of binary
digits stored on a digital device
 These are the units you need to know for IGCSE:
Unit Symbol Value
Bit b 1 or 0
Nibble 4b
Byte B 8b
Kibibyte KiB 1,024 B (210)
Mebibyte MiB 1,024 KiB (220)
Gibibyte GiB 1.024 MiB (230)
Tebibyte TiB 1,024 GiB (240)
Megabyte vs Mebibyte
 1 kibibyte (1KiB) = 1024 bytes (1024 B) - binary prefixes (to the power of
2)
 1 kilobyte (1KB) = 1000 bytes (1000 B) - decimal prefixes (to the power of
10)
Converting between units
 It is often a requirement of the exam to be able to convert between
different units of data, for example bytes to mebibytes (larger) or kibibytes
to bytes (smaller)
 This process involves division, moving up in size of unit
and multiplication, moving down in size of unit
 When dealing with all units bigger than a byte we use multiples
of 1024 (210)
 For example, 2000 kibibytes in mebibytes would be 2000 / 1024 = 1.95
MiB and 2 tebibytes in gibibytes would be 2 * 1024 = 2048 GiB
 When dealing with bits and bytes the same process is used with the
value 8 as there are 8 bits in a byte
 For example, 24 bits in bytes would be 24 / 8 = 3 B and 10 bytes in bits
would be 10 * 8 = 80 b
Unit

Multiply by 8 ⇑ Divide by 8 ⇓
Bit
Byte

Multiply by 1024 ⇑ Kibibyte Divide by 1024 ⇓


Mebibyte
Gibibyte
Tebibyte

You might also like