Chapter 1 O Level Computer SC (Fawad)
Chapter 1 O Level Computer SC (Fawad)
Number Binary
System System
Motivation Explanation
Why Binary System Denary System
•
can be processed by a computer
Computer contains millions and millions of tiny switches, which can be turned
Eg. 365
on and off.
102 =100 101 =10 100 =1
• Therefore, the binary system is chosen as the way for a computer to represent any
sort of data.
3 6 5
On = 1 Off = 0
Explanation: Multiply the digit value (eg.3) by the place value (eg. 100)
Binary Denary 22 =4 21 =2 20 =1
Binary 1 1 1
Denary
(1x4) + (1x2) + (1x1) = 7 in denary
1
07/03/2024
1 0 1 1 1 1 1 0 0
Explanation: Multiply the digit value (eg.1) by the place value (eg. 8).
Then sum it all up!
Convert 5 to binary:
ANSWER
24 =16 23 =8 22 =4 21 =2 20 =1
5
5 2 2 1
remainder
1 1 1 0 0
Read the remainder
2 1 remainder 0 from bottom to top
2 0 remainder 1
(1x16) + (1x8) + (1x4) + (0x2) + (0x1)
= 28 in denary Answer: 101
Convert 39 to binary:
What is the binary form of 42?
39
2 19 remainder
1 25 =32 24 =16 23 =8 22 =4 21 =2 20 =1
39
2 9 remainder
1
2 4 remainder
1 Read the remainder
from bottom to top
2 2 remainder
0
2 1 remainder
0
2 0 remainder
1
Answer: 100111
2
07/03/2024
42
Hundredth Tenth Ones
2 10 remainder
1
2 5 remainder
0 Read the remainder
from bottom to top
2 2 remainder
1
2 1 remainder
0
2 0 remainder
1
Answer: 101010
Binary System
22 21 20 1 0 1 0
(1x4) + (1x2)
1 1 1 + (1x1) = 7
1 0 1 0
(1x8) + (1x2) = 10 in denary
3
07/03/2024
38
2 19 remainder
0
38
2 9 remainder
1
2 4 remainder
1 Read the remainder
from bottom to top
2 2 remainder
0
2 1 remainder
0
2 0 remainder
1
Answer: 100110
ANSWER
Hexadecimal
System
Motivation Explanation
Hexadecimal System Hexadecimal System
Denary System Binary System
Denary 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Hexadecimal System
Binary 0, 1
Hexadecimal 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 , A, B, C, D, E, F ?2 =? ?1 =? ?0 =?
3 E 5
4
07/03/2024
Explanation
Hexadecimal System Conversion
Denary System Binary System
3 6 5 1 0 1 Binary Hexadecimal
(3x100) + (6x10) + (5x1) = 365 (1x4) + (0x2) + (1x1) = 5
Hexadecimal System
Hexadecimal Binary
162 =256 161 =16 160 =1
3 E 5
• Since 16 = 24 this means that FOUR binary digits are equivalent to each
101111100001
hexadecimal digit.
101 1 111 0 0 0 01
B E 1
ANSWER : BE1
10 000111111101
What is the hexadecimal form of
0111010011100?
00 10 0001 1111 1101
2 1 F D
ANSWER : 21FD
5
07/03/2024
ANSWER
F 9 3 5
0111010011100
1111 0011 0101
0000 1110 1001 1100 1001
0 E 9 C
B F 0 8
What is the binary form of
BF08?
1011 0000 1000
1111
Eg. "111"
Hexadecimal Denary
22 =4 21 =2 20 =1
Denary Hexadecimal 1 1 1
6
07/03/2024
4 5 A C 8 F
Note: A=10 Note: C=12, F=15
(4x256) + (5x16) + (10x1) = 1114 in denary (12x256) + (8x16) + (15x1) = 3215 in denary
163 =4096 162 =256 161 =16 160 =1 163 =4096 162 =256 161 =16 160 =1
B F 0 8 B F 0 8
5 2004/16 = 125
5
2004
2 2 remainder
1 remainder = 4
Read the remainder
16 125 remainder 4
2 1 remainder
0 from bottom to top
16 7 13
2 0 1
remainder
remainder
125/16 = 7
remainder = 13
16 0 remainder 7
Note: 13=D
7
07/03/2024
What is the hexadecimal form of 3179? What is the hexadecimal form of 3179?
Answer: C6B
PA S T Y E A R Q U E S T I O N ANSWER
PA S T Y E A R Q U E S T I O N ANSWER
8
07/03/2024
Binary Hexadecimal
Chapter 1.2
110101111110
Use of hexadecimal 1AFD39
100111001
system
Brainstorm time: Why is Hexadecimal used?
• One hex digit represents four binary digits • Error codes are often shown as
• The hex number is far easier for humans to hexadecimal values.
remember, copy and work with • These numbers refer to the memory
• Four uses of the hexadecimal system location of the error.
• They are generated by the computer.
• The programmer needs to know how to
interpret the hexadecimal error codes.
9
07/03/2024
00-1C-B3-4F-25-FE
Form 2
00_1C_C3_4F_23_AE NN:NN:NN:DD:DD:DD
Message 2
00:1C:B3:4F:25:FE
Mac address uniquely identify a device on a Local Area Network Mac Address comes with 2 forms
Usage 3: Internet
Usage 2: MAC address Explanation Protocol Addresses Explanation
10
07/03/2024
PA S T Y E A R Q U E S T I O N ANSWER
PA S T Y E A R Q U E S T I O N ANSWER
1
Addition of 0+0=0 9
0+9=9 +1
binary number
9+0=9
10
9 + 1 = 10
11
07/03/2024
How do we perform add and carry in denary? How do we perform add and carry in binary?
1 1
56 6+9 = 15 (>9) 0+0=0
1+5+7 = 13 (>9) 0+1=1
+79 1+0=1
1 35 1 + 1 = 10
How do we perform add and carry in binary? How do we perform add and carry in binary?
1 1 1
00100111 Perform
12
07/03/2024
• Binary shift is a process that a CPU uses to perform • For a CPU to multiply a binary number, the number
multiplication and division. needs to be shifted to the left and will fill the
remaining gaps with zeros.
13
07/03/2024
• For a CPU to multiply a binary number, the number Examples: 101100 (Binary)
needs to be shifted to the right. 32 16 8 4 2 1
1 0 1 1 0 0
Examples: 10110 (Binary)
32 16 8 4 2 1
0 1 0 1 1 0
Examples: 1011 (Binary)
32 16 8 4 2 1
0 0 1 0 1 1
Examples: 101100 (Binary) • Registers contained within the CPU often have 8-bits limits
32 16 8 4 2 1 on the amount of data they can hold at any one time.
1 0 1 1 0 0 • The multiplying shifting process can cause bits to be lost at
one end of the register, and zeros added at the opposite
end.
Divide by 2, shift 1 place to the right 10110 • This process is known as losing the most significant bit.
Divide by 4, shift 2 place to the right 1011
Divide by 8, shift 3 place to the right 101
BINARY SHIFTING WITH 8-BIT BINARY NUMBERS BINARY SHIFTING WITH 8-BIT BINARY NUMBERS
Examples: 10110101 (181 in denary) The same process can happen when dividing an 8-bit
128 64 32 16 8 4 2 1 binary number.
1 0 1 1 0 1 0 1 Example: 10111101 (189 in denary)
128 64 32 16 8 4 2 1
1 0 1 1 1 1 0 1
10110101 -> 01101010 Divide this number by 32 (move 5 places to the right)
106 in denary
128 64 32 16 8 4 2 1
0 0 0 0 0 1 0 1
The bit lost is called the most significant bit, and when it The division shift produces the 11101
Least
is shifted beyond the furthest-column the binary data that binary number 101 = 5, not Significant
is stored loses precision due to overflow. 5.9 that arithmetic suggests. bit
14
07/03/2024
TWO COMPLEMENTS
Lesson1.5:
Chapter Objectives
Two
• A PROCESSOR CAN ALSO REPRESENT NEGATIVE
Complements
Last lesson on the binary system
NUMBERS.
BINARY SHIFTING TWO COMPLEMENTS • ONE OF THE METHOD THAT A PROCESS
Represent REPRESENT NEGATIVE NUMBERS IS CALLED
Multiplication
negative TWO'S COMPLEMENT.
and division of
number in
binary numbers
binary
0 = POSITIVE
1 = NEGATIVE
Examples:13
Step 1: Convert 13 into binary.
1101 in binary
Convert 19 into a Two's complement
Step 2: Put the number into the place value column
-128 64 32 16 8 4 2 1
8-bit Integer
0 0 0 0 1 1 0 1
15
07/03/2024
CONVERT POSITIVE BINARY INTEGER TO A TWO'S COMPLEMENT 8-BIT INTEGER CONVERT TWO'S COMPLEMENT 8-BIT INTEGER TO A POSITIVE BINARY INTEGER
Examples: 10010011
Step 1: Put the number into the place value column
-128 64 32 16 8 4 2 1
1 0 0 1 0 0 1 1 Convert 10110011 (Two's Complement)
to denary
Step 2: The left-most bit is 1, this means that it is a
negative number.
Step 3: Compute the denary value as usual.
(1x -128) + (1x16) + (1x2) + (1x1)
= -128 + 16 + 2 + 1
= -109
16
07/03/2024
CONVERT NEGATIVE BINARY NUMBERS IN TWO'S COMPLEMENT FORMAT AND CONVERTING NEGATIVE DENARY NUMBERS INTO BINARY NUMBERS IN TWO’S
CONVERT TO DENARY COMPLEMENT FORMAT
DIY
17
07/03/2024
65 Convert to (+)
1 +1
18
07/03/2024
19
07/03/2024
20
07/03/2024
Chapter 1.7
Measurement of Data
Storage and Calculation
of file size
Measurement Memory
of Data
Size
Storage
System
• 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
Based on the SI (base 10) system of units where
4 bits = 1 nibble 1 kilo is equal to 1000.
21
07/03/2024
Memory Memory
Size As memory size is actually measured in terms of powers of 2... Size
System 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
Based on the IEC (base 2) system of units where
1 kilo is equal to 1024 (2^10).
Memory DIY
Size
System
Converting Gib, Mib, Kib into bytes Convert the size of GTA-V to bytes
64 GiB 72 GiB
= 64 x 1024 = 65536 MiB = 72 x 1024 = 73728 MiB
= 65536 x 1024 = 67108864 KiB = 65536 x 1024 = 75497472 KiB
= 67108864 x 1024 = 68719476736 Bytes = 75497472 x 1024 = 77309411328 Bytes
Calculation Calculation
of file of file
size size - Image
22
07/03/2024
Formula
2px
00 01
image resolution (pixels) x colour depths (bits) 10 11
Total pixels = 2 x 2 = 4 Colour depth = 2
Calculation = (2x2) x 2
= 8 bits = 1 byte
23
07/03/2024
DANSWER DIY
Question: Question:
Calculate the size of this image in Bytes. Calculate the size of this image in Bytes (Answer: 8388608 bytes).
Answer: What is the size of the image in MiB.
2048 x 2048 x 16 = 67108864 bits
= 67108864/8
= 8388608 bytes
24
07/03/2024
Calculation
of file
Example 1 - Stereo Sound DIY
size - Sound
An audio CD has a sample rate of 44100 and a sample resolution of 16 bits. The 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 music being sampled uses two channels to allow for stereo recording. Calculate the
file size for a 60-minute recording. file size for a 25-minute recording.
DIY PA S T Y E A R Q U E S T I O N
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
ANSWER
25
07/03/2024
LOSSY LOSSLESS
FILE FILE
COMPRESSI COMPRESSI
ON ON
26
07/03/2024
27
07/03/2024
• ALL THE DATA FROM THE ORIGINAL 1. CAN BE USED FOR LOSSLESS COMPRESSION OF A NUMBER OF
UNCOMPRESSED FILE CAN BE DIFFERENT FILE FORMATS.
RUN-
RECONSTRUCTED LENGTH 2. IT REDUCES THE SIZE OF A STRING OF ADJACENT, IDENTICAL DATA.
LOSSLESS • THIS IS IMPORTANT FOR FILES WHERE LOSS ENCODING
bytes
3,2,5,2,4
2,4,3,4,3
1.6.1.6.2
0, 15,1
TO BE
CONTINUE
28
07/03/2024
PA S T Y E A R Q U E S T I O N ANSWER
PA S T Y E A R Q U E S T I O N ANSWER
29