1 Data Representation
1 Data Representation
DATA
AE73F9? REPRESENTATAION
On = 1 Off = 0
Denary System
Eg. 365
102 =100 101 =10 100 =1
3 6 5
Explanation: Multiply the digit value (eg.3) by the place value (eg. 100)
Denary Binary
Binary Denary
22 =4 21 =2 20 =1
1 1 1
Eg. "1011"
23 =8 22 =4 21 =2 20 =1
1 0 1 1
Explanation: Multiply the digit value (eg.1) by the place value (eg. 8).
Then sum it all up!
1 1 1 0 0
Binary Denary
ANSWER
24 =16 23 =8 22 =4 21 =2 20 =1
1 1 1 0 0
(1x16) + (1x8) + (1x4) + (0x2) + (0x1)
= 28 in denary
Denary Binary Explanation
Convert 5 to binary:
5 2 2 1
remainder
Read the remainder
2 1 remainder 0 from bottom to top
2 0 remainder 1
Answer: 101
Denary Binary Explanation
Convert 39 to binary:
39
2 19 remainder
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
Denary Binary
ANSWER
Convert 42 to binary:
42
2 21 remainder
0
42
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
Denary System RECAP
(7x100) + (6x10)
7 6 5
+ (5x1) = 765
Hundredth Tenth Ones
Denary System RECAP
(7x100) + (6x10)
7 6 5
+ (5x1) = 765
Binary System
22 21 20
(1x4) + (1x2)
1 1 1 + (1x1) = 7
Binary Denary
1 0 1 0
Binary Denary
ANSWER
23 =8 22 =4 21 =2 20 =1
1 0 1 0
(1x8) + (1x2) = 10 in denary
Denary Binary
ANSWER
Convert 38 to binary:
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
PA S T Y EA R Q U ES T I O N
ANSWER
Hexadecimal
System
Hexadecimal System
• It is a base 16 system.
• It uses 16 digits to represent each value
Denary 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Binary 0, 1
Hexadecimal 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 , A, B, C, D, E, F
Explanation
Hexadecimal System
Denary System Binary System
3 6 5 1 0 1
(3x100) + (6x10) + (5x1) = 365 (1x4) + (0x2) + (1x1) = 5
Hexadecimal System
?2 =? ?1 =? ?0 =?
3 E 5
Explanation
Hexadecimal System
Denary System Binary System
3 6 5 1 0 1
(3x100) + (6x10) + (5x1) = 365 (1x4) + (0x2) + (1x1) = 5
Hexadecimal System
3 E 5
Conversion
Binary Hexadecimal
Hexadecimal Binary
Binary Hexadecimal Explanation
• Since 16 = 24 this means that FOUR binary digits are equivalent to each
hexadecimal digit.
Binary Hexadecimal Explanation
101111100001
101 1 111 0 0 0 01
B E 1
ANSWER : BE1
Binary Hexadecimal Explanation
10 000111111101
2 1 F D
ANSWER : 21FD
Binary Hexadecimal
ANSWER
0111010011100
0 E 9 C
Hexadecimal Binary Explanation
F 9 3 5
1111 0011 0101
1001
B F 0 8
1011 0000 1000
1111
Hexadecimal Denary
Denary Hexadecimal
Binary Denary
Eg. "111"
22 =4 21 =2 20 =1
1 1 1
Eg. "45A"
162 =256 161 =16 160 =1
4 5 A
Note: A=10
Eg. "C8F"
162 =256 161 =16 160 =1
C 8 F
Note: C=12, F=15
B F 0 8
Hexadecimal Denary
ANSWER
B F 0 8
Convert 5 to binary:
5 2 2 1
remainder
Read the remainder
2 1 remainder
0 from bottom to top
2 0 remainder
1
Answer: 101
Denary Hexadecimal Explanation
Eg. "2004"
2004/16 = 125
remainder = 4 2004
16 125 remainder 4
16 7 remainder
13
125/16 = 7
16 0 remainder 7
remainder = 13
Note: 13=D
Answer: 7D4
Denary Hexadecimal
3179/16 = ?
3179
16 198 remainder ?
16 ? remainder
?
16 ? remainder ?
Denary Hexadecimal
3179/16 = 198
remainder = 11 3179
16 198 remainder 11
198/16 = 12 16 12 remainder 6
remainder = 6 16 0 remainder 12
Answer: C6B
PA S T Y EA R Q U ES T I O N
ANSWER
PA S T Y EA R Q U ES T I O N
ANSWER
Use of hexadecimal
system
Use of hexadecimal system
Binary Hexadecimal
110101111110
1AFD39
100111001
00_1C_B3_4F_25_FE
Message 00_1C_C3_4F_23_AE
00-1C-B3-4F-25-FE
Form 2
NN:NN:NN:DD:DD:DD
2
00:1C:B3:4F:25:FE
00-1C-B3 4F-25-FE
1
0+0=0 9
0+9=9 +1
9+0=9
10
9 + 1 = 10
Addition of binary number
1 1
6+9 = 15 (>9)
56
1+5+7 = 13 (>9)
+79
1 35
Addition of binary number Explanation
0+0=0
0+1=1
1+0=1
1 + 1 = 10
Addition of binary number Explanation
1 1 1
00100111
+01001010
0 1110 001
Addition of binary number
Perform
01111110 + 00111110
Addition of binary number Explanation
BINARY SHIFTING
Multiplication
and division of
binary numbers
BINARY SHIFTING
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.
BINARY SHIFTING WITH 8-BIT BINARY NUMBERS
TWO COMPLEMENTS
Represent
negative
number in
binary
TWO COMPLEMENTS
0 = POSITIVE
1 = NEGATIVE
CONVERT POSITIVE BINARY INTEGER TO A TWO'S COMPLEMENT 8-BIT INTEGER
Examples:13
Step 1: Convert 13 into binary.
1101 in binary
Step 2: Put the number into the place value column
-128 64 32 16 8 4 2 1
0 0 0 0 1 1 0 1
Examples:19
Step 1: Convert 19 into binary.
10011 in binary
Step 2: Put the number into the place value column
-128 64 32 16 8 4 2 1
0 0 0 1 0 0 1 1
Step 3: Ensure that the the leftmost bit is 0 (+).
Answer: 00010011
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
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
Convert 10110011 (Two's Complement)
to denary
CONVERT NEGATIVE BINARY NUMBERS IN TWO'S COMPLEMENT FORMAT AND
CONVERT TO DENARY
Examples: 10110011
Step 1: Put the number into the place value column
-128 64 32 16 8 4 2 1
1 0 1 1 0 0 1 1
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) (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.
10111100
+ 1
10111101
Step 5: This gives us -67.
-128 64 32 16 8 4 2 1
1 0 1 1 1 1 0 1
-128 + 32 + 16 + 8 + 4 + 1 = -67
Convert -65 to 8 bit two's complement
binary number
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.
10111110
+ 1
10111111
65 Convert to (+)
1 +1
To convert the analogue data to digital, the sound waves are sampled at
regular time intervals. The amplitude of the sound cannot be measured
precisely, so approximate values are stored.
The number of bits used to represent sound amplitude in digital
sound recording, as known as bit depth
Sampling rate is the
number of sound samples
taken per second. This is
measured in hertz (Hz),
where 1Hz means ‘one
sample per second’.
Activity 1.15
(page no. 31)
1.3 Measurement of
data storage and
Calculation of file size
Measurement
of Data
• Most computer system have storage which is measured in bytes.
Storage
A byte is a unit of data that is eight binary digit long. A byte can
be used to represent a character, for example a letter, a number
or a symbol.
• A bit is the basic unit of all computing memory storage terms
and is either 1 or 0.
• A byte is a abbreviated with the capital letter ‘B’.(A bit is a one
eighth of a byte and is abbreviated with a lower case ‘b’.
• The byte is the smallest unit of memory in a computer.
8 bits = 1 byte
4 bits = 1 nibble
Measurement
of Data
Storage
Memory
Size
System
68719476736 Bytes
= 68719476736 Bytes / 1024 = 67108864 KiB
= 67108864 KiB / 1024 = 65536 MiB
= 65536 MiB / 1024 = 64 GiB
Memory
Size
System
Converting Gib, Mib, Kib into bytes
64 GiB
= 64 x 1024 = 65536 MiB
= 65536 x 1024 = 67108864 KiB
= 67108864 x 1024 = 68719476736 Bytes
DIY
72 GiB
= 72 x 1024 = 73728 MiB
= 65536 x 1024 = 75497472 KiB
= 75497472 x 1024 = 77309411328 Bytes
Calculation
of file
size
Image Audio
Calculation
of file
size - Image
Formula
2px
00 01
10 11
Total pixels = 2 x 2 = 4 Colour depth = 2
Calculation = (2x2) x 2
= 8 bits = 1 byte
Calculation Example 2
of file
size - Image
Formula : image resolution (pixels) x colour depths (bits)
Question:
Image Resolution = 1024 x 1080
Colour depth = 32
2 Now multiply number of pixels by colour depth then divide by 8 to give the
number of bytes = 1105920 × 32 = 35389440/8 bytes = 4423680 bytes
2 Now multiply number of pixels by colour depth = 4 194 304 × 16 = 67 108 864 bits
3 Now divide number of bits by 8 to find the number of bytes in the file = (67 108 864)/8
= 8 388 608 bytes
4 Now divide by 1024 × 1024 to convert to MiB = (8 388 608)/(1 048 576) = 8 MiB.
Calculation
of file Example
size - Image
Question:
Image Resolution = 1024 x 1080
Colour depth = 32
Sample Rate (in Hz) x Sample Resolution (in bits) x length of sample (in seconds)
Calculation
of file
size - Sound
Example 3 from Book
Formula : sample rate (in Hz) × sample resolution (in bits) × length
An audio CD has a sample rate of 44100 and a sample resolution of 16bits. The
music being sampled uses two channels to allow for stereo recording. Calculate the
file size for a 60-minute recording.
1 Size of file =
sample rate (in Hz) × sample resolution (in bits) × length of sample (in seconds)
3 Multiply by 2 since there are two channels being used = 5 080 320 000 bits
4 Divide by 8 to find number of bytes = (5 080 320 000)/8 = 635 040 000
5 Divide by 1024 × 1024 to convert to MiB = 635 040 000 / 1 048 576 = 605MiB.
Calculation
of file
size - 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.
LOSSY LOSSLESS
FILE FILE
COMPRESSION COMPRESSION
LOSSY FILE
COMPRESSION
• FILE COMPRESSION ALGORITHM ELIMINATES
UNNECESSARY DATA FROM THE FILE.
• ORIGINAL FILE CANNOT BE RECONSTRUCTED ONCE IT HAS
BEEN COMPRESSED.
• IMAGE - REDUCE THE RESOLUTION // COLOUR DEPTH
• SOUND - REDUCE THE SAMPLING RATE // SAMPLING
RESOLUTION
• SOME LOSSY FILE COMPRESSION ALGORITHMS ARE:
MPEG-3 MPEG-4 JPEG
LOSSY FILE
• A COMPRESSION TECHNOLOGY THAT
COMPRESSION
REDUCES THE SIZE OF A NORMAL MUSIC
FILE BY ABOUT 90%.
SECRET
MPEG-3 • REMOVE SOUNDS
OUTSIDE THE
HUMAN EAR RANGE
• ELIMINATE THE
SOFTER SOUND -
PERCEPTUAL MUSIC
SHAPING
LOSSY FILE
COMPRESSION ALLOWS STORAGE OF MULTIMEDIA FILES
RATHER THAN JUST SOUND.
SECRET
MPEG-4 • MOVIES CAN BE
STREAMED
USING THE MP4
FORMAT
WITHOUT
LOSING ANY
REAL
DISCERNIBLE
QUALITY
LOSSY FILE
A LOSSY COMPRESSION ALGORITHM USED
COMPRESSION
FOR BITMAP IMAGES. ORIGINAL FILE CAN NO
LONGER BE CONSTRUCTED
SECRET
JPEG • REMOVE
COLOUR
SHADES
(HUMAN CAN'T
NOTICE THEM)
LOSSY FILE
COMPRESSION
LOSSY FILE
COMPRESSION
DATA
COMPRESSION
16
bytes
LOSSLESS
FILE Does not work well when no repeated data! RUN-LENGTH
COMPRESSION ENCODING
IN
ACTION
TO BE
CONTINUE
REDUCE REDUCE
COLOUR IMAGE
DEPTH RESOLUTION
LOSSY FILE
A LOSSY COMPRESSION ALGORITHM USED
COMPRESSION
FOR BITMAP IMAGES. ORIGINAL FILE CAN NO
LONGER BE CONSTRUCTED
SECRET
JPEG • REMOVE
COLOUR
SHADES
(HUMAN CAN'T
NOTICE THEM)
PA S T Y EA R Q U ES T I O N
ANSWER
PA S T Y EA R Q U ES T I O N
ANSWER
51
127
153
116
255
15
143
179
112
238
41-00101001
6C-01101100
6B-107 00011101 + 01100110
98-62 =10000011
2634-A4A Decimal value:29 + 102
= 131