1.1 Data Representation EMK Notes
1.1 Data Representation EMK Notes
Number System
“Number system is a way of representing amounts or quantity of something”
Types of Number System
Reading remainder from bottom to Top and appending to right each time gives
(11001011)2 . This is binary equivalent of (203)10.
Binary to Denary System:
Convert following binary number, 0011000111100110, into a denary number.
To convert this number to denary, each time a 1 appears in a column, column value is
added to total: 8192 + 4096 + 256 + 128 + 64 + 32 + 4 + 2 = 12 774
Hexadecimal Number System
To convert from binary to hexadecimal, start from right and moving left, split binary
number into groups of 4 bits.
If last group has less than 4 bits, then simply fill in with 0s from left. Take each group of
4 bits and convert it into equivalent hexadecimal digit.
Everything you see on a computer, images, sounds, games, text, videos, etc. Whatever it
is, it will be stored as a string of ones and zeroes.
Coding used in a computer system is based on bits being grouped together with eight
bits representing a byte. Right-hand bit is referred to as the least significant bit and
the left-hand bit as the most significant or top bit.
Bits in a byte are numbered right to left starting at bit 0 and ending at bit 7.
Negative numbers are represented using sign and magnitude or two's complement.
Smallest possible number using sign and magnitude method representation is -127 (or
11111111) and the largest possible number is +127 (or 01111111).
One's complement:
It is defined as the binary number obtained if each binary digit is
individually subtracted from 1 which, in practice, means that each 0 is switched to 1
and each 1 switched to 0.
Lowest and highest integer values that is possible to represent in two’s complement
using a 8 bit is -128 and +127 respectively.
Binary Arithmetic
Binary Addition:
For binary addition, starting at the least significant position applies.
Rules for the addition of binary digits are:
0+0=0
0+1=1
1 + 1 = 0 with a carry of 1
1 + 1 + 0 = 0 with a carry of 1
1 + 1 + 1 = 1 with a carry of 1
Example: Add 0 0 1 0 0 1 0 1 (37 in denary) and 0 0 1 1 1 0 1 0 (58 in denary)
Binary Subtraction:
Starting at the least significant position applies. Rules for subtraction of
binary digits are:
0– 0 = 0
0 – 1 = 1 after a borrow
1– 0 = 1
1– 1 = 0
Example:
Subtraction of binary equivalent of denary 11 from binary equivalent of denary 14
can be done as.
Total is number bigger than 8 digits, and when this happens CPU drops overflow
digit because the computer cannot store it anywhere, and computer thinks 255 + 1 = 0.
Most CPUs use much bigger word size than 8 bits. Many PC have 64-bit CPU. 64-bit CPU can
handle number larger than 18 quintillion (18,446,744,073,709,551,615 to be precise).
BCD is an encoding for decimal numbers in which each digit is represented by its own
binary sequence. In BCD we can use the binary number from 0000-1001 only, which
are the decimal equivalent from 0-9 respectively. Example
Suppose if a number have single decimal digit then it’s equivalent BCD will be the
respective four binary digits of that decimal number.
Note: If a denary number with more than one digit is to be converted to BCD, there are
two options for BCD;
Method # 1:
We store one BCD code in one byte leaving four bits unused.
Example: BCD representations of the denary digits 8503:
Method # 2:
In this method, we packed BCD where two 4-bit codes are stored in one byte.
Example:
BCD representations of the denary digits 8503:
9 + 5 = 14 in denary.
[1001] + [0101] = [1110] in binary.
which gives us two nibbles, [0001] and [0100] which correspond to "1" and "4"
respectively. This gives us the 14 in BCD which is the correct result.
Correction factor.
To counteract this in BCD arithmetic, processor recognize that an impossible
value has been produced and apply a method to remedy this. Remedy is to add 0110
whenever problem is detected.
For 0 to 9 decimal numbers both binary and BCD is equal but when decimal
number is more than one digit, BCD differs from binary.
Sixth bit changes from 1 to 0 when comparing lower and uppercase characters. This makes
conversion between the two an easy operation.
Character sets (such as a to z, 0 to 9, and so on) are grouped together in sequence, which
speeds up usability.
Unicode
Unicode allows characters in a code form to represent all languages of
world, thus supporting many operating systems, search engines and internet browsers
used globally.
Unicode overlap with standard ASCII code, since the first 128 (English) characters are
the same. Unicode can support 65,536 different characters in total as it take two bytes
Code Point:
Unicode has its own special terminology and symbolism. For example, a
character code is referred to as a 'code point'.
Code point is identified by U+ followed by a 4-digit hexadecimal number.
Example: U+0041 which is code point corresponding to alphabetic character A. The
0041 are hexadecimal characters representing two bytes.
Note: Code points U+0000 to U+00FF define characters which are a duplicate of those
in standard ASCII.
Important Points about Unicode:
Unicode create a universal standard that covered all languages and all writing
systems.
Produce a more efficient coding system than ASCII
Adopt uniform encoding where each character is encoded as 16-bit or 32-bit
code.
Create unambiguous encoding where each 16-bit or 32-bit value always
represents same character
Reserve part of code for private use to enable a user to assign codes for their
own characters and symbols.
Similarity between ASCII and Unicode are; 9618/O/N/22/P11
Both represent each character using a unique code
Unicode will contain all characters that ASCII contains // ASCII is a subset of Unicode.
A problem arises when the computer retrieves a piece of data from its memory.
Imagine that the data is 01000001. Is this the number 65, or is it A?
They are both stored in the same way, so how can it tell the difference?
First 128 characters in Unicode are the ASCII
The answer is codes.
that characters and numbers are stored in different parts of the memory,
so it knows which one it is by knowing where about it was stored.
Decimal Prefix
A prefix to define the magnitude of a value. Examples are kilo( K), mega (M) , giga (G) , tera (T)
and peta (P) representing factors of 103 , 106 , 109 , 1012 and 1015 respectively.
Binary Prefix
A prefix to define the magnitude of a value. Examples are kibi (Ki), mebi (Mi) , gibi (Gi) , tebi (Ti)
and pebi (Pi) representing factors of 210 , 220 , 230 , 240 and 250 respectively.
Example: How many mp3 files of size 2.4 MiB could be stored on a 4 GiB USB?
Solution:
******************
Exam Style Question
Q#1 Find how -28 would be expressed in two's complement notation?
**************