Chapter 1 Data Representation
Chapter 1 Data Representation
DATA REPRESENTATION
DATA AND INFORMATION
Denary Numbers
• In our daily lives we use denary 0 10 20 31 41 51
1 11 21 32 42 52
number system.
2 12 23 33 43 53
• This system uses the digits 0-9 . 3 13 24 34 44 54
4 14 25 35 45 55
• It is called base 10 number
5 15 26 36 46 …..
system. that means the units it 6 16 27 37 47
uses increases by the power of 10. 7 17 28 38 48
8 18 29 39 49
9 19 30 40 50
245
• increased by power of 10
increased by power of 10
128 64 32 16 8 4 2 1
• With the help of above chart we can derive a sequence of number, that sequence is
known as Binary Notation.
CONVERTING FROM BINARY TO DENARY
Denar 8 + 4 + 0
y + 0
• To convert 8 bit binary numbers into denary we need to add together all
the binary units that are marked as required by the digit 1.
• If we take the binary number 10010100 we can draw a table to see what
units are7 needed:
2 2 6
2 5
2 4
2
3 2
2 2
1
2
0
128 64 32 16 8 4 2 1
1 0 0 1 0 1 0 0
Denary : 128+16+4=148
CONVERTING FROM DENARY TO BINARY
• Method 1
27 26 25 24 23 22 21 20
128 64 32 16 8 4 2 1
1 0 0 0 1 1 1 0
CONVERTING FROM DENARY TO BINARY
1. Used in colour codes : Hexadecimal (hex) is used as a notation for colour in HTML.
2. Used in error codes: Standard Windows error message codes are given in
hexadecimal notation, for example error code 404 (meaning 'File not found') is a
hexadecimal notation.
3. Used in IPv6 address :128-bit addresses that take the form of eight groups of hex
digits; for example,
A8FB:7A88:FFF0:0FFF:3D21:2085:66FB:F0FA
4. Used in MAC addresses : Media Access Control (MAC) addresses are 12-digit
hexadecimal numbers that uniquely identify each different device in a network. An
example of MAC address would be 00-1B-63-84-45-E6.
HEXADECIMAL NUMBER SYSTEM
• Hexadecimal uses 16 symbols, the numbers 0-9 and the letters A-F.
• The notation for each denary number between 0 and 15 is shown in Table .
Denary 0 1 2 3 4 5 6 7 8 9 10 11 12 1 14 1
3 5
Hexadeci 0 1 2 3 4 5 6 7 8 9 A B C D E F
mal
CONVERTING FROM BINARY TO HEXADECIMAL
8 4 2 1 8 4 2 1 8 4 2 1
1 0 1 1 1 1 0 0 1 0 0 1
• Take each of the hexadecimal digits and multiply it by the heading values.
• Add all the resultant totals together to give the denary number.
• Remember that the hex digits A → F need to be first converted to the
values 10 → 15 before carrying out the multiplication.
CONVERTING FROM HEXADECIMAL TO
DENARY
• 1AB
1 A B
1 10 11
256 16 1
1 10 11
1x 256 16 x10 1 x11
256 + 160 + 11
= 427
METHOD 1
• 55
161 160
16 1
3x16 =48 and 7x1
55/16 = 3
=7 remainder 7
Hexadecimal 3 7
Denary 48 + 7
48 + 7 = 55
CONVERTING FROM DENARY TO HEXADECIMAL
METHOD 2
•(76 + 62 = 138) 62 0 0 1 1 1 1 1 0
Sum 1 0 0 0 1 0 1 0
CONCEPT OF OVERFLOW:
•Overflow error is the result of carrying out a calculation that produces a value too large for
the computer’s allocated word size.
128 64 32 16 8 4 2 1
0 1 0 0 0 0 1 1 • Invert all the
67 =
values is
128 64 32 16 8 4 2 1 called one’s
67 0 1 0 0 0 0 1 1 complement
1’s 1 0 1 1 1 1 0 0
• Add 1 in the
complement
+ 1
inverted
1 0 1 1 1 1 0 1
binary value
-128 64 32 16 8 4 2 1
-67 1 0 1 1 1 1 0 1 -128 + 32 + 16 + 8 + 4 + 1
= = - 67
CONVERT -75 TO BINARY IN TWO’S
COMPLEMENT FORMAT
LOGICAL BINARY SHIFTS
Logical Binary Shifts
Left Shifts :
RIGHT SHIFTS :
• Each shift right is
12 64 32 16 8 4 2 1
8 equivalent to dividing
Denary value: the binary number by
0 1 1 0 0 1 0 0 100 2n (where n is the
number of places
12 64 32 16 8 4 2 1
shifted)
8
Denary value:
0 0 1 1 0 0 1 0 50
• If the rightmost 1 bits
are lost while shifting
12 64 32 16 8 4 2 1 to the right, an error
8 will occur because the
Denary value: limit of the maximum
0 0 0 1 1 0 0 1 25 number of right shifts
possible will have been
exceeded.