Denary
Hexadecimal
Explanation
Eg. "45A"
4
5
A
(4x256) + (5x16) + (10x1) = 1114 in denary
Note: A=10
162 =256
161 =16
160 =1
Denary
Hexadecimal
Explanation
Eg. "45A"
4
5
A
(4x256) + (5x16) + (10x1) = 1114 in denary
Note: A=10
162 =256
161 =16
160 =1
Denary
Hexadecimal
Explanation
Eg. "C8F"
C
8
F
(12x256) + (8x16) + (15x1) = 3215 in denary
Note: C=12, F=15
162 =256
161 =16
160 =1
DIY
What is the denary form of BF08?
Denary
Hexadecimal
DIY
B
F
0
8
162 =256
161 =16
160 =1
163 =4096
DIY
ANSWER
Denary
Hexadecimal
DIY
B
F
0
8
(11x4096) + (15x256) + (0x16) + (8x1) = 48904 in denary
162 =256
161 =16
160 =1
163 =4096
5
2
2
2
1
1
0
Denary
Binary
Convert 5 to binary:
5
RECAP
(Method 2)
remainder
remainder
2
0
remainder
1
Read the remainder
from bottom to top
Answer: 101
Denary
Hexadecimal
Explanation
Eg. "2004"
2004
16
16
125
remainder
2004/16 =
4
125/16 =
7
13
remainder
16
0
remainder
7
Answer: 7D4
Note: 13=D
125
remainder = 4
7
remainder = 13
DIY
What is the hexadecimal form of 3179?
Denary
Hexadecimal
DIY
3179
16
16
198
remainder
?
?
?
remainder
16
?
remainder
?
3179/16 = ?
DIY
16
6
What is the hexadecimal form of 3179?
Denary
Hexadecimal
DIY
3179
16
198
remainder
11
12
remainder
16
0
remainder
12
3179/16
198/16
Answer: C6B
= 198
remainder = 11
= 12
remainder = 6
PAST YEAR QUESTION
ANSWER
PAST YEAR QUESTION
ANSWER
Chapter 1.2
Use of hexadecimal system
Discussion Time
Use of hexadecimal system
Binary
Hexadecimal
110101111110100111001
1AFD39
Brainstorm time: Why is Hexadecimal used?
Explanation
Use of hexadecimal system
One hex digit represents four binary digits
The hex number is far easier for humans to remember, copy and work with
Four uses of the hexadecimal system
Explanation
Usage 1: Error Code
Error codes are often shown as hexadecimal values.
These numbers refer to the memory location of the error.
They are generated by the computer.
The programmer needs to know how to interpret the hexadecimal error codes.
Explanation
Usage 1: Error Code
Explanation
Usage 2: MAC address
Media Access Control (MAC) address refers to
a number which uniquely identifies a device on a network.
The MAC address refers to the network interface card (NIC) which is part of the device
The MAC address is rarely changed so that a particular device can always be identified no matter where it is.
Explanation
Usage 2: MAC address
00_1C_B3_4F_25_FE
00_1C_C3_4F_23_AE
Mac address uniquely identify a device on a Local Area Network
Message
Explanation
Usage 2: MAC address
00-1C-B3-4F-25-FE
NN-NN-NN-DD-DD-DD
00:1C:B3:4F:25:FE
NN:NN:NN:DD:DD:DD
Form 1
Form 2 2
Mac Address comes with 2 forms
Explanation
Usage 2: MAC address
00-1C-B3
4F-25-FE
Identity number of the manufacturer
Serial number of
a device
Eg. 00 – 14 – 22 which identifies devices made by Dell
00 – a0 – c9 which identifies devices made by Intel
Explanation
Usage 3: Internet Protocol Addresses
Each device connected to a network is given an address known as the Internet Protocol address
An IPv4 address is a 32-bit number written in denary or hexadecimal form e.g. 109.108.158.1 (or 77.76.9e.01 in hex)
IPv4 has recently been improved upon by the adoption of IPv6. An IPv6 address is a 128-bit number broken down into 16-bit chunks, represented by a hexadecimal number.
Eg. a8f b:7a88:fff0:0fff:3d21:2085:66f b:f0fa
Explanation
Usage 4: HyperText Markup Language (HTML) colour code
HyperText Mark-up Language (HTML) is used when writing and developing web pages.
It is not a programming language, but a markup language.
A mark-up language is used in the processing, definition and presentation of text.
Explanation
Overview
The 4 usages of Hexadecimals - EMIH
1. E - Error Codes
2. M - MAC Address
3. I - Internet Protocol Address
4. H - HTML Colour Code
PAST YEAR QUESTION
ANSWER
PAST YEAR QUESTION
ANSWER
Chapter 1.3
Addition of
binary number
Explanation
How do we perform add and carry in denary?
0 + 0 = 0
0 + 9 = 9
9 + 0 = 9
9 + 1 = 10
9
+1
0
1
1
Addition of binary number
Explanation
How do we perform add and carry in denary?
56
+79
6+9 = 15 (>9)
5
1
1+5+7 = 13 (>9)
3
1
1
Addition of binary number
Explanation
How do we perform add and carry in binary?
0 + 0 = 0
0 + 1 = 1
1 + 0 = 1
1 + 1 = 10
Addition of binary number
Explanation
How do we perform add and carry in binary?
00100111
+01001010
1
1
0
0
1
0
1
1
1
1
0
Addition of binary number
DIY
How do we perform add and carry in binary?
Perform
01111110 + 00111110
Addition of binary number
Explanation
The overflow condition
01101110
+11011110
1
1
0
0
1
0
1
1
0
1
1
1
1
0
1
Addition of binary number
Addition of binary number
Explanation
The overflow condition
01101110
+11011110
1
1
0
0
1
0
1
1
0
1
1
1
1
0
1
The maximum denary of an 8-bit binary number (11111111) is (28 - 1 ) = 255
The generation of a 9th bit is a clear indication that the sum has exceeded this value.
This is known as an overflow error. The sum is too big to be stored using 8 bits.
Explanation
The overflow condition
01101110
+11011110
1
1
0
0
1
0
1
1
0
1
1
1
1
0
1
01101110 = 110
\11011110 = 222
110 + 222 = 322
322 > 255 (overflow)
The sum is too big to be stored in a 8 bit binary.
Addition of binary number
Lesson Objectives
Last lesson on the binary system
BINARY SHIFTING
Multiplication and division of binary numbers
TWO COMPLEMENTS
Represent negative number in binary
Chapter 1.4: Binary Shifting
BINARY SHIFTING
Binary shift is a process that a CPU uses to perform multiplication and division.
BINARY SHIFTING - MULTIPLICATION
For a CPU to multiply a binary number, the number needs to be shifted to the left and will fill the remaining gaps with zeros.
16
32
8
4
2
1
64
16
32
8
4
2
1
64
16
32
8
4
2
1
64
BINARY SHIFTING - MULTIPLICATION
Examples: 111 (Binary)
0
0
0
1
1
1
0
Examples: 1110 (Binary)
0
0
0
1
1
1
0
Examples: 11100 (Binary)
0
0
0
1
1
1
0
16
32
8
4
2
1
64
BINARY SHIFTING - MULTIPLICATION
Examples: 111 (Binary)
0
0
0
1
1
1
0
Multiply by 2, shift 1 place to the left
1110
Multiply by 4, shift 2 place to the left
Multiply by 8, shift 3 place to the left
11100
111000
Multiply by 2^n, shift n place to the left
BINARY SHIFTING - DIVISION
For a CPU to multiply a binary number, the number needs to be shifted to the right.
16
32
8
4
2
1
16
32
8
4
2
1
16
32
8
4
2
1
BINARY SHIFTING - DIVISION
Examples: 101100 (Binary)
0
1
1
1
0
0
Examples: 10110 (Binary)
1
0
0
1
1
0
Examples: 1011 (Binary)
1
0
1
0
1
0
16
32
8
4
2
1
BINARY SHIFTING - DIVISION
Examples: 101100 (Binary)
0
1
1
1
0
0
Divide by 2, shift 1 place to the right
10110
Divide by 4, shift 2 place to the right
Divide by 8, shift 3 place to the right
1011
101
Divide by 2^n, shift n place to the right
BINARY SHIFTING WITH 8-BIT BINARY NUMBERS
Registers contained within the CPU often have 8-bits limits on the amount of data they can hold at any one time.
The multiplying shifting process can cause bits to be lost at one end of the register, and zeros added at the opposite end.
This process is known as losing the most significant bit.
16
32
8
4
2
1
64
128
BINARY SHIFTING WITH 8-BIT BINARY NUMBERS
Examples: 10110101 (181 in denary)
1
1
0
1
0
1
0
1
10110101 -> 01101010
106 in denary
The bit lost is called the most significant bit, and when it is shifted beyond the furthest-column the binary data that is stored loses precision due to overflow.
16
32
8
4
2
1
64
128
16
32
8
4
2
1
64
128
BINARY SHIFTING WITH 8-BIT BINARY NUMBERS
The same process can happen when dividing an 8-bit binary number.
1
1
1
1
0
1
0
1
Example: 10111101 (189 in denary)
Divide this number by 32 (move 5 places to the right)
0
0
0
1
0
1
0
0
Least
Significant bit
The division shift produces the binary number 101 = 5, not 5.9 that arithmetic suggests.
11101
Lesson Objectives
Last lesson on the binary system
BINARY SHIFTING
Multiplication and division of binary numbers
TWO COMPLEMENTS
Represent negative number in binary
Chapter 1.5: Two Complements
TWO COMPLEMENTS
A PROCESSOR CAN ALSO REPRESENT NEGATIVE NUMBERS.
ONE OF THE METHOD THAT A PROCESS REPRESENT NEGATIVE NUMBERS IS CALLED TWO'S COMPLEMENT.
TWO COMPLEMENTS
TWO COMPLEMENTS
TO REPRESENT NEGATIVE NUMBERS, IT IS IMPORTANT TO THINK ABOUT THE PLACE VALUE OF THE FURTHEST-LEFT BIT IN A DIFFERENT WAY.
PROCESSOR CAN BE SET UP TO SEE THE BIT IN THE EIGHTH COLUMN AS A SIGN BIT.
0 = POSITIVE
1 = NEGATIVE
16
32
8
4
2
64
-128
CONVERT POSITIVE BINARY INTEGER TO A TWO'S COMPLEMENT 8-BIT INTEGER
Examples:13
0
0
1
1
0
0
0
1
1
Step 2: Put the number into the place value column
Step 3: Ensure that the the leftmost bit is 0 (+).
Step 1: Convert 13 into binary.
1101 in binary
DIY
Convert 19 into a Two's complement
8-bit Integer
16
32
8
4
2
64
-128
CONVERT POSITIVE BINARY INTEGER TO A TWO'S COMPLEMENT 8-BIT INTEGER
Examples:19
1
0
0
0
1
0
0
1
1
Step 2: Put the number into the place value column
Step 3: Ensure that the the leftmost bit is 0 (+).
Step 1: Convert 19 into binary.
10011 in binary
Answer: 00010011
16
32
8
4
2
64
-128
CONVERT TWO'S COMPLEMENT 8-BIT INTEGER TO A POSITIVE BINARY INTEGER
Examples: Convert 00010011 (two's complement) to denary
1
0
0
0
1
0
0
1
1
Step 1: Put the number into the place value column
Step 2: This shows that it is a positive number, we can just convert the binary into denary directly.
Step 3: Calculate the denary value.
(1x16) + (1x2) + (1x1) = 19
Convert 01010011 (two's complement)
to denary
DIY
16
32
8
4
2
64
-128
CONVERT TWO'S COMPLEMENT 8-BIT INTEGER TO A POSITIVE BINARY INTEGER
Examples: Convert 01010011 (two's complement) to denary
1
0
0
0
1
1
0
1
1
Step 1: Put the number into the place value column
Step 2: This shows that it is a positive number, we can just convert the binary into denary directly.
Step 3: Calculate the denary value.
(1x64) + (1x16) + (1x2) + (1x1) = 83
16
32
8
4
2
64
-128
CONVERT NEGATIVE BINARY NUMBERS IN TWO'S COMPLEMENT FORMAT AND CONVERT TO DENARY
Examples: 10010011
1
0
0
0
1
0
1
1
1
Step 1: Put the number into the place value column
Step 3: Compute the denary value as usual.
Step 2: The left-most bit is 1, this means that it is a negative number.
(1x -128) + (1x16) + (1x2) + (1x1)
= -128 + 16 + 2 + 1
= -109
Convert 10110011 (Two's Complement)
to denary
DIY
16
32
8
4
2
64
-128
CONVERT NEGATIVE BINARY NUMBERS IN TWO'S COMPLEMENT FORMAT AND CONVERT TO DENARY
Examples: 10110011
1
1
0
0
1
0
1
1
1
Step 1: Put the number into the place value column
Step 3: Compute the denary value as usual.
Step 2: The left-most bit is 1, this means that it is a negative number.
(1x -128) (1x32)+ (1x16) + (1x2) + (1x1)
= -128 + 32 + 16 + 2 + 1
= -77
CONVERTING NEGATIVE DENARY NUMBERS INTO BINARY NUMBERS IN TWO’S COMPLEMENT FORMAT
Examples: -67
Step 1: Convert the number to positive.
67
Step 2: Write the number in binary form (8 bits).
01000011
Step 3: Invert each binary value.
10111100
Step 4: Add 1 to the binary number.
1
10111101
+
10111100
Step 5: This gives us -67.
16
32
8
4
2
64
-128
1
1
1
1
0
0
1
1
1
-128 + 32 + 16 + 8 + 4 + 1 = -67
Convert -65 to 8 bit two's complement
binary number
DIY
CONVERTING NEGATIVE DENARY NUMBERS INTO BINARY NUMBERS IN TWO’S COMPLEMENT FORMAT
Examples: -65
Step 1: Convert the number to positive.
65
Step 2: Write the number in binary form (8 bits).
01000001
Step 3: Invert each binary value.
10111110
Step 4: Add 1 to the binary number.
1
10111111
+
Step 5: This gives us -65.
16
32
8
4
2
64
-128
1
1
1
1
1
0
1
1
1
-128 + 32 + 16 + 8 + 4 + 2 + 1 = -65
10111110
Summary: Convert negative denary to two's complement
Examples: -65
01000001
10111110
65
1
10111111
Convert to (+)
Convert to binary
Invert the digit
+1
Final result
Chapter 1.3
eight
Exercise for ASCII
Using the ASCII table convert the word “BLUE” to binary.
Using the ASCII table below, convert the following binary coded message into a word.
Activity
Using the ASCII table, try to decode this message:
01000011 01101111 01001101 01110000 01110101 01110100 01100101 01110010 01010011 01100011 01101001 01000101 01101110 01100011 01100101 01101001 01110011 01100110 01110101 01101110 00100001
each letter will be represented as an 8-bit binary number.
The ASCII character set represents characters using 8-bit binary numbers. This means that it can represent up to 256 characters (0 to 255).
A Unicode character set represents characters using 16-bit binary numbers.
This means it can represent a much greater number of characters, approximately 65 000.
1.1.3 Unicode
Sound is a vibration that propagates as an audible wave of pressure through the air. In human physiology ,sound is the reception of this waves and the perception by the brain.
The sound is generated by a sound source which is the vibrating diaphragm of a speaker and detected by microphone or human ears.
We can visualize sound as an analogue wave and to store the sound in binary we need to convert the analogue signal to a digital signal. This process is called analogue to digital conversion.
There are two main factors:
Sample rate :The sample rate is how often an audio analogue sound wave is sampled .
Sample resolution: Each of those sampling rates, what is the level of detail depth or fertility that analogue audio was recorded at .
OR
Number of bits that are used to represent each sample .
NOTE:
Amplitude is the distance between the wave's resting position and its maximum displacement.
Frequency is the number of waves that pass by a specific point per second. 2.
The meter is the SI unit of amplitude. The unit of frequency measurement is Hertz (Hz).
The number of bits used to represent sound amplitude in digital sound recording, as known as bit depth
Image file types
BMP
JPG
GIF
PNG
1.2 How do computers represent images
Creating an Image
Each pixel is given a binary value
Each value represents a different colour
Using one bit per pixel allows only 2 values, 0 and 1
1 = Black, 0 = White
Red, Green, Blue color system(RGB)
The different intensity of the 3 primary colors make up the color you want
The intensity will be represented by denary or hex numbers
For example: (255,0,0) / #FF0000 is red
RGB images
Measurement of Data Storage and Calculation of file size
Measurement of Data Storage
A bit is the basic unit of all computing memory storage terms and is either 1 or 0.
The byte is the smallest unit of memory in a computer.
8 bits = 1 byte
4 bits = 1 nibble
Memory
Size
System
Based on the SI (base 10) system of units where
1 kilo is equal to 1000.
SI-international System of Units
Memory
Size
System
Based on the IEC (base 2) system of units where
1 kilo is equal to 1024 (2^10).
As memory size is actually measured in terms of powers of 2...
Memory
Size
System
Converting Bytes into KiB, MiB and GiB
68719476736 Bytes
68719476736 Bytes / 1024
=
= 67108864 KiB
=
67108864 KiB / 1024
= 65536 MiB
=
65536 MiB / 1024
= 64 GiB
Sound file formats
.WAV – uncompressed files(Wave Form Audio)
.FLAC or .M4A lossless compression, slightly smaller files-Free Lossless Audio Codec,MPEG-Audio 4
.MP3 – Lossy compression, much smaller files
MP-4 /MPEG-4 file format –Motion picters Experts Group
MP4 is a digital multimedia format most commonly used to store video and audio
It can also be used to store subtitles and still images
It allows different
multimedia streams (video, audio, text) to be combined into one file
MIDI files
MIDI stands for Musical Instrument Digital Interface
A MIDI file:
is not a recording of a live
music source
is a set of instructions for digital
instruments to play synthesised sounds
can be used to synchronise an orchestra
of digital instruments to play simultaneously
uses up to 1000 times less disk space than a
conventional recording
is commonly used for mobile phone ringtones
Conversion between bits and bytes
Memory
Size
System
Converting Gib, Mib, Kib into bytes
= 68719476736 Bytes
64 x 1024
=
= 65536 MiB
=
65536 x 1024
= 67108864 KiB
=
67108864 x 1024
64 GiB
Calculation
of file
size
Image
Audio
Calculation
of file
size - Image
Image Resolution - The number of pixels that make up an image.
The higher the image resolution, the higher the quality of the image.
Calculation
of file
size - Image
Formula
image resolution (pixels) x colour depths (bits)
Calculation
of file
size - Image
Example 1
00
01
10
11
2px
2px
Total pixels = 2 x 2 = 4
Colour depth = 2
Calculation = (2x2) x 2
= 8 bits = 1 byte
Calculation
of file
size - Image
Example 2
Formula : image resolution (pixels) x colour depths (bits)
Question:
Image Resolution = 1024 x 1080
Colour depth = 32
Calculate the size of this image in Bytes.
Workings:
1024 x 1080 = 1105920 pixels
1105920 x 32 = 35389440 bits
Answer in byte: 35389440/8 = 4423680 bytes
Calculation
of file
size - Image
Example 2
Question:
Image Resolution = 1024 x 1080
Colour depth = 32
Calculate the size of this image in Bytes. How many photograph of this size would fit onto a memory stick of 64Gib.
Each image = 4423680 bytes
First convert 64 Gib into bytes:
64 x 1024 = 65536 MiB
65536 x 1024 = 67108864 KiB
67108864 x 1024 = 68719476736 bytes
Calculation
of file
size - Image
Example 2
Question:
Image Resolution = 1024 x 1080
Colour depth = 32
Calculate the size of this image in Bytes. How many photograph of this size would fit onto a memory stick of 64Gib.
Each image = 4423680 bytes
First convert 64 Gib into bytes = 68719476736 bytes
68719476736/4423680 = 15534 photos.
DIY
Question:
Image Resolution = 2048 x 2048
Colour depth = 16
Calculate the size of this image in Bytes.
DANSWER
Question:
Image Resolution = 2048 x 2048
Colour depth = 16
Calculate the size of this image in Bytes.
Answer:
2048 x 2048 x 16 = 67108864 bits
= 67108864/8
= 8388608 bytes
DIY
Question:
Image Resolution = 2048 x 2048
Colour depth = 16
Calculate the size of this image in Bytes (Answer: 8388608 bytes).
What is the size of the image in MiB.
DANSWER
Question:
Image Resolution = 2048 x 2048
Colour depth = 16
Calculate the size of this image in Bytes (Answer: 8388608 bytes).
What is the size of the image in MiB.
8388608 / 1024 = 8192 KiB
8192 / 1024 = 8 MiB
Calculation
of file
size - Sound
Formula
Sample Rate (in Hz) x Sample Resolution (in bits) x length of sample (in seconds)
Calculation
of file
size - Sound
Mono Sound vs Stereo Sound
Comparison
The difference between monophonic (mono) and stereophonic (stereo) sound is the number of channels used to record and playback audio.
Mono signals are recorded and played back using a single audio channel, while stereo sounds are recorded and played back using two audio channels.
Calculation
of file
size - Sound
Example 1 - Mono Sound
Question:
Sample Rate: 44100
Sample Resolution: 8 bits
Length of the music: 20 seconds
Calculate the size of the audio in KiB.
44100 x 8 x 20 = 7056000 bits
7056000/8 = 882000 bytes
882000 / 1024 = 861.328 KiB
Calculation
of file
size - Sound
Example 1 - Stereo Sound
An audio CD has a sample rate of 44100 and a sample resolution of 16 bits. The music being sampled uses two channels to allow for stereo recording. Calculate the file size for a 60-minute recording.
44100 x 16 x 3600 = 2540160000 bits
2540160000 x 2 = 5080320000 bits
5080320000 / 8 = 635040000 bytes
635040000 / 1024 = 620156.25 KiB
620156.25 / 1024 = 605.62 MiB
DIY
An audio CD has a sample rate of 44100 and a sample resolution of 8 bits. The music being sampled uses two channels to allow for stereo recording. Calculate the file size for a 25-minute recording.
DIY
An audio CD has a sample rate of 44100 and a sample resolution of 8 bits. The music being sampled uses two channels to allow for stereo recording. Calculate the file size for a 25-minute recording in MiB.
44100 x 8 x 1500 = 529200000 bits
529200000 x 2 = 1058400000 bits
1058400000 / 8 = 132300000 bytes
132300000 / 1024 = 129199.218 KiB
129199.218 / 1024 = 126.17 MiB
PAST YEAR QUESTION
ANSWER
DATA
COMPRESSION
DATA COMPRESSION
DATA COMPRESSION
FILE SIZE OF IMAGES AND SOUND CAN BE VERY LARGE.
THEREFORE, DATA COMPRESSION IS NEEDED TO REDUCE THE SIZE OF A FILE.
DATA
COMPRESSION
WHAT ARE SOME BENEFITS OF REDUCING THE FILE SIZE?
DATA
COMPRESSION
Benefits of Data Compression
SAVE STORAGE SPACE
REDUCE
STREAMING TIME
REDUCE
TIME TAKEN TO UPLOAD AND DOWNLOAD MEDIA
REDUCE
COST
LOSSY
FILE
COMPRESSION
LOSSLESS
FILE
COMPRESSION
DATA
COMPRESSION
Two types of image compression
Lossy Compression (JPG)
Lossless Compression (PNG)
What is compression?
A method that uses an algorithm to reduce the size of a file.
3. Data Compression
• Removes data permanently
• Much smaller file sizes but some loss of quality
e.g. reducing the resolution:
Note: Mainly used in image or a sound file .
3.1 Lossy Compression
128KiB
21KiB
Note:
1. The size of the sound file can be reduced by reducing the sample rate and the sample resolution
2. The lossy compression algorithm for an image file could reduce the size of the file by reducing the colur depth .
• Lossless compression reduces the file size without permanent loss of data, e.g. run length encoding (RLE)
This algorithm will group together repeating pixels and store how many times they occur.
3.2 Lossless Compression
Run Length Encoding (RLE)
If W is white, Y is yellow, R is red and G is green, RLE could compress the image into the following data:
12W, 3Y, 5W, 2Y, 1R, 2Y, 3W, 2Y, 3R, 2Y, 3W, 2Y, 1R, 2Y, 5W, 3Y, 7W, 1G, 5W, 2G,
1W, 1G, 1W, 2G, 4W, 3G, 7W, 1G, 4W.
3.2 Lossless Compression
DIY
DIY
REDUCE COLOUR
DEPTH
REDUCE
IMAGE
RESOLUTION
PAST YEAR QUESTION
ANSWER
PAST YEAR QUESTION
ANSWER