Computer Organisation & Architecture Dept of Informatics
CHAPTER 2
Data Representation
Bits, bytes, and words
Bit = Binary digit = 0 or 1
Byte = a sequence of 8 bits = 00000000, 00000001... Or 11111111
Word = a sequence of N bits where N = 16, 32, 64 depending on the computer
Measuring Amount of Data/Memory Capacity
1 kilobyte = 1 KB = 210 bytes = 1024 bytes (appx 103 bytes)
1 Megabyte = 1 MB = 220 bytes = 1,048,576 bytes (appx 106 bytes)
1 Gigabyte = 1 GB = 230 bytes = 1,073,741,824 bytes (appx 109 bytes)
We can represent Boolean truth values in a virtual computer using bits: 1 = true, 0 = false.
Representation of numeric data
A digital system can understand positional number system only where there are only a few
symbols called digits and these symbols represent different values depending on the position
they occupy in the number.
A value of each digit in a number can be determined using
The digit
The position of the digit in the number
The base of the number system (where base is defined as the total number of digits
available in the number system).
Decimal Number System
The number system that we use in our day-to-day life is the decimal number system. Decimal
number system has base 10 as it uses 10 digits from 0 to 9. In decimal number system, the
successive positions to the left of the decimal point represent units, tens, hundreds, thousands
and so on.
Each position represents a specific power of the base (10). For example, the decimal number
1234 consists of the digit 4 in the units position, 3 in the tens position, 2 in the hundreds
position, and 1 in the thousands position, and its value can be written as
(1x1000)+ (2x100) + (3x10) + (4xl)
(1x103)+ (2x102) + (3x101) + (4xl00)
1000 + 200 + 30 + 1
1234
1
Computer Organisation & Architecture Dept of Informatics
As a computer programmer or an IT professional, you should understand the following number
systems which are frequently used in computers.
Number System & Description
1 Binary Number System
Base 2. Digits used: 0, 1
2 Octal Number System
Base 8. Digits used: 0 to 7
3 Hexa Decimal Number System
Base 16. Digits used: 0 to 9, Letters used: A- F
Binary Number System
Uses two digits, 0 and 1.
Also called base 2 number system
Each position in a binary number represents a 0 power of the base (2). Example 20
Last position in a binary number represents a x power of the base (2). Example 2x
where x represents the last position - 1.
Example Calculating Decimal Equivalent:
Binary Number: 101012
Step Binary Number Decimal Number
Step 1 101012 ((1 x 24) + (0 x 23) + (1 x 22) + (0 x 21) + (1 x 20))10
Step 2 101012 (16 + 0 + 4 + 0 + 1)10
Step 3 101012 2110
Note: 101012 is normally written as 10101.
Octal Number System
Uses eight digits, 0,1,2,3,4,5,6,7.
Also called base 8 number system
Each position in a octal number represents a 0 power of the base (8). Example 80
Last position in a octal number represents a x power of the base (8). Example 8x
where x represents the last position - 1.
Example Calculating Decimal Equivalent:
Octal Number: 125708
Step Octal Number Decimal Number
Step 1 125708 ((1 x 8 ) + (2 x 83) + (5 x 82) + (7 x 81) + (0 x 80))10
4
Step 2 125708 (4096 + 1024 + 320 + 56 + 0)10
549610
Step 3 125708
2
Computer Organisation & Architecture Dept of Informatics
Hexadecimal Number System
Uses 10 digits and 6 letters, 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F.
Letters represents numbers starting from 10. A = 10. B = 11, C = 12, D = 13, E = 14,
F = 15.
Also called base 16 number system
First position in a hexadecimal number represents a 0 power of the base (16).
Example 160
Last position in a hexadecimal number represents a x power of the base (16). Example
16x where x represents the last position - 1
Example Calculating Decimal Equivalent:
Hexadecimal Number: 19FDE16
Hexa
Step Decimal Number
Number
Step 1 19FDE16 ((1 x 164) + (9 x 163) + (F x 162) + (D x 161) + (E x 160))10
((1 x 164) + (9 x 163) + (15 x 162) + (13 x 161) + (14 x
Step 2 19FDE16
160))10
Step 3 19FDE16 (65536+ 36864 + 3840 + 208 + 14)10
Step 4 19FDE16 10646210
Representation of Non-Numeric data
A data which can't be measure in numerical form is called none numerical data. Usually, this
data is calculated in word form like a, b, c, d etc. this type of data can only be identified in
word format.
The computer internally has only two “characters”: 0 and 1. So the question is: how can we
represent our characters listed above using 0 and 1? Note that in this context there is no
numerical value associated with any character; each is simply a symbol. A simple solution is
to assign a unique pattern (code) of 0s and 1s for each of our characters (i.e., encode each
using 0 and 1). Since there are many possible ways of doing this, we need a standard so that
every computer can use the same encoding to enable sharing of data among computers.
Example:
As you may know, numbers are represented in bits. For example:
00000000 = 0, 00000001 = 1, 00000010 = 2, 00000011 = 3
Text is represented by these same numbers. Every letter and character are represented by a
single number. So, for example if you wanted to store "hello":
h = 104, e = 101, l = 108, l = 108, o = 111.
So, it would be stored as: 104 101 108 108 111
There are 3 types of non-numeric representation methods.
3
Computer Organisation & Architecture Dept of Informatics
1. ASCII
American Standard Code for Information Interchange (ASCII) is the most widely used
alphanumeric code set. It is used for representing uppercase and lower case English
letters (i.e., Latin alphabet), numbers and punctuations. There are 128 standard ASCII
codes which are represented using 7-bits (also called as 7-bit ASCII).
2. EBCDIC
Extended Binary Coded Decimal Interchange Code (EBCDIC) is used primarily by
large IBM computers (super computer and main frames). It is not widely used, in
contrast to ASCII.
3. Unicode
Although ASCII is heavily used it cannot represent more than 128 characters.
However, there are hundreds of alphabets (character sets) in the world and they have
many characters in them. So, it is not possible to use ASCII to represent characters in a
language like Amharic. (Many proprietary schemes got around this problem, but there
is no standard way for this). Therefore, there was a need for new standard coding
system which can support a large number of characters. Unicode is the solution.
Unicode uses 32 bits to overcome the limitation of the number of characters. Unicode
system can represent multiple character sets, including Amharic and others.
Fixed Point Number Representation
The shifting process above is the key to understand fixed point number representation. To
represent a real number in computers (or any hardware in general), we can define a fixed
point number type simply by implicitly fixing the binary point to be at some position of a
numeral. We will then simply adhere to this implicit convention when we represent numbers.
To define a fixed point type conceptually, all we need are two parameters:
Width of the number representation, and
Binary point position within the number
We will use the notation fixed<w,b> for the rest of this article, where w denotes the number of
bits used as a whole (the Width of a number), and b denotes the position of binary point
counting from the least significant bit (counting from 0).
For example, fixed<8,3> denotes a 8-bit fixed point number, of which 3 right most bits are
fractional. Therefore, the bit pattern:
0 0 0 1 0 1 1 0
Represents a real number:
4
Computer Organisation & Architecture Dept of Informatics
00010.1102
= 1 * 21 + 1 * 2-1 + 1 * 2-1
= 2 + 0.5 + 0.25
= 2.75
Note that on a computer; a bit patter can represents anything. Therefore the same bit pattern,
if we "cast" it to another type, such as a fixed<8,5> type, will represents the number:
000.101102
= 1 * 2-1 + 1 * 2-3 + 1 * 2-4
= 0.5 + 0.125 + 0.0625
= 0.6875
If we treat this bit patter as integer, it represents the number:
101102
= 1 * 24 + 1 * 22 + 1 * 21
= 16 + 4 + 2
= 22
Floating point number representation
As the name implies, floating point numbers are numbers that contain floating decimal
points. For example, the numbers 5.5, 0.001, and -2,345.6789 are floating point numbers.
Numbers that do not have decimal places are called integers. Computers recognize real
numbers that contain fractions as floating point numbers. When a calculation includes a
floating point number, it is called a "floating point calculation."
A real number (that is, a number that can contain a fractional part). The following are
floating-point numbers:
3.0 or -111.5 or ½ or 3E-5.
The last example is a computer shorthand for scientific notation. It means 3*10-5 (or 10 to
the negative 5th power multiplied by 3).
5
Computer Organisation & Architecture Dept of Informatics
Complements
Binary system complements
As the binary system has base r = 2. So the two types of complements for the binary system
are 2's complement and 1's complement.
1's complement
The 1's complement of a number is found by changing all 1's to 0's and all 0's to 1's. This is
called as taking complement or 1's complement. Example of 1's Complement is as follows.
2's complement
The 2's complement of binary number is obtained by adding 1 to the Least Significant Bit
(LSB) of 1's complement of the number.
2's complement = 1's complement + 1
Example:
1. 2’s complement of the following 5 bit number
2. 2’s complement of the following 8 bit number
00101001
11010110 First, invert the bits
+ 00000001 then, add 1
= 11010111
The 2’s complement of 00101001 is 11010111
3. 2’s complement of the following 8 bit number
00011100
11100011 After, invert the bits. 0 becomes 1, 1 becomes 0.
+ 00000001 Then we add 1.
11100100 Results 2’s Complement.