1 Data Representation
1 Data Representation
representation
1.1 NUMBER SYSTEMS
Understand how and why computers use
binary to represent all forms of data
Introduction: Binary System
-Binary system works in base of 2
-The only possible values are 0 or 1
-A typical binary value is a string of 0s and 1s e.g. 0101010000
-Computer has to translate every single instruction into Binary
Translation of ‘Welcome’ in Binary would be:
01010111 01100101 01101100 01100011 01101111 01101101 01100101
Why does Computer Store Data in Binary
-Data
-Instruction
-Number
-Part of image / small image
-A sound / sound sample / small soundtrack
-ASCII value / Unicode value / character
EXPLAIN THE DIFFERENCES BETWEEN BINARY AND DENARY
SYSTEM
• -A binary number system is a base -2 system
• -A binary number system uses 0 and 1 values/ denary number system uses 0 to 9 values
1. 010 2 = 2 10
2. 1001 2 = 910
3. 100011 2 = 35 10
4. 1001001 2 =?
7310
CONVERSION FROM DECIMAL/DENARY TO BINARY
10010 = ?2
01001011
10001110
00000001 01010011
Introduction: Hexadecimal number system
• Base -16 number system
• 16 unique symbols: 0-9 and letters A-F
• Decimal 10=A, 11=B, 12=C, 13=D, 14=E, 15=F
• Hexadecimal numbers can represent every byte (8 bits) as two
hexadecimal digits.
• Easier for humans to read hexadecimal rather than binary.
E.g: 3AD16 ,A2B16
Hexadecimal to binary
Practice Problems
1. Convert FDA16 to an equivalent binary number
01110001010012
0 E 2 916
0E2916
Binary to Hexadecimal
11010102
110 10102
011010102
6 A16
6A16
1010100010111
1 5 1 7 16
111100111101111
7 9 E F 16
Decimal to Hexadecimal
910 ? 16
(8976)10 ? 16
(2310)16
9870 ? 16
Hexadecimal to Decimal
AF1016
= (3246)10
= 40960 + 3840 + 16
= (44816)10
L.O: Understand how and why hexadecimal is
used as a beneficial method of data representation.
• Hex is useful because large numbers can be represented using fewer digits.
• For example, color values and MAC addresses are often represented in hex.
• Programmers often use hex to represent binary values as they are simpler to write and check than
when using binary.
• Hexadecimal is easier to debug and locate errors in data.
1.2 Binary Manipulation and
Negative numbers
• Binary Addition:
Binary Addition example
Practice problem in binary addition
1100101 + 101000
010001101
101000000 + 10010
0101010010
Add two positive 8-bit binary integers
An overflow error will occur if the value is greater
than 255 in an 8-bit register
Negative Binary Numbers
How negative numbers represent as binary?
The methods exist that can be used to represent negative binary numbers and it is called two’s complement.
For Example:
• To get –45 :
• Invert the value of 45 1101 0010
• Add 1 with inverted values 1
1101 0011 (not the values is -45)
2’s Complement method:
Example #1
5 = 00000101
Complement Digits
11111010
+1
Add 1
-5 = 11111011
Example #2
-13 = 11110011
Complement Digits
00001100
+1
Add 1
13 = 00001101
Logical Binary Shifts
PAST PAPER 0478-2021-oct-nov-0478-w21-qp-11
PAST PAPER 0478-2021-oct-nov-0478-w21-qp-12
PAST PAPER 0478-2021-oct-nov-0478-w21-qp-12
PAST PAPER 0478-2021-oct-nov-0478-w21-qp-13
PAST PAPER 0478-2021-oct-nov-0478-w21-qp-13
PAST PAPER 0478-2021-oct-nov-0478-w21-qp-13
PAST PAPER 0478/12/F/M/21
(b) Give the largest denary value that can be stored in the 8-bit binary 255
register.
PAST PAPER 0478-2021-oct-nov-0478-w21-qp-13
(ii) The values in the MAC address are hexadecimal values. Convert the three given
hexadecimal values into 8-bit binary.
14 ......................................................................................................................................
A0 ......................................................................................................................................
C9 ......................................................................................................................................