Number Systems
Number Systems
Number Systems
Two types of number systems are:
Non-positional number system
- Use symbols such as I for 1, II for 2, III for 3, IIII for 4, IIIII for 5, etc
- Each symbol represents the same value regardless of its position in the number
- The symbols are simply added to find out the value of a particular number
Difficulty
It is difficult to perform arithmetic with such a number system
=2586
- In order to be specific about which number system we are referring to, it is a common practice to
indicate the base as a subscript. Thus, we write:
101012 = 2110
Bit
- Bit stands for binary digit.
- A bit in computer terminology means either a 0 or a 1.
- A binary number consisting of n bits is called an n-bit number.
Memory Dump
- Every computer stores numbers, letters, and other special characters in binary form.
- Computer professionals need to know raw data contents of a computer’s memory on several
occasions.
- A commonly used way of doing this is to print/display raw memory contents, which is called
memory dump.
Binary Decimal
Equivalent
000 0
001 1
010 2
011 3
100 4
101 5
110 6
111 7
2
Principle of Information Technology (CST-1111)
Example
47068 = ?10
47068 = 4 * 83 + 7 * 82 + 0 *81 + 6 * 80
= 4 * 512 + 7 *64 + 0 + 6* 1
= 2048 + 448 + 0 + 6
= 250210
119 0
14 7
1 6
0 1
Example 5456 = ?4
Solution: Step 1: Convert from base 6 to base 10
5456 = 5 * 62 + 4 * 61 + 5 * 60
= 5 * 36 + 4 * 6 + 5 * 1
3
Principle of Information Technology (CST-1111)
= 180 + 24 + 5
= 20910
Step 2: Convert 20910 to base 4
4 209 Remainders
52 1
13 0
3 1
0 3
Shortcut Method for Converting an Octal Number to its Equivalent Binary Number
Method
Step 1: Convert each octal digit to a 3 digit binary number (the octal digits may be treated as decimal
for this conversion)
Step 2: Combine all the resulting binary groups (of 3 digits each) into a single binary number
Example
5628 = ?2
Step 1: Convert each octal digit to 3 binary digits 58 = 1012, 68 = 1102, 28 = 0102
Step 2: Combine the binary groups 5628 = 101 110 010
Hence, 5628 = 1011100102
Shortcut Method for Converting a Binary Number to its Equivalent Hexadecimal Number
Method
Step 1: Divide the binary digits into groups of four starting from the right
Step 2: Combine each group of four binary digits to one hexadecimal digit
Example
1111012 = (?)16
Step 1: Divide the binary digits into groups of four starting from the right
0011 1101
Step 2: Convert each group into a hexadecimal digit
00112 = 0 * 23 + 0 *22 + 1 * 21 + 1 * 20
= 310 = 316
11012 = 1 x 23 + 1 x 22 + 0 x 21 + 1 x 20
4
Principle of Information Technology (CST-1111)
= 1310 = D16
Hence, 1111012 = 3D16
Shortcut Method for Converting a Hexadecimal Number to its Equivalent Binary Number
Method
Step 1: Convert the decimal equivalent of each hexadecimal digit to a 4 digit binary number
Step 2: Combine all the resulting binary groups (of 4 digits each) in a single binary number
Example
2AB16 = ?2
Step 1: Convert each hexadecimal digit to a 4 digit binary number
216 = 210 = 00102
A16 = 1010 = 10102
B16 = 1110 = 10112
Fractional Numbers
Fractional numbers are formed same way as decimal number system
In general, a number in a number system with base b would be written as: an an-1… a0 . a-1 a-2 … a-m
And would be interpreted to mean: an * bn + an-1 * bn-1 + … + a0 * b0 + a-1 * b-1 + a-2 * b-2 + … + a-m *
b-m
The symbols an, an-1, …, a-m in above representation should be one of the b symbols allowed in the
number system
Formation of Fractional Numb Binary Point
y Number System)
Position 4 3 2 1 0. -1 -2 -3 -4
Example
110.1012 = 1 x 22 + 1 x 21 + 0 x 20 + 1 x 2-1 + 0 x 2-2 + 1 x 2-3
= 4 + 2 + 0 + 0.5 + 0 + 0.125
= 6.62510
Octal Point
Position 3 2 1 0 . -1 -2 -3
Example
5
Principle of Information Technology (CST-1111)
= 87.687510
System
Number system
Octal number system
Hexadecimal system
Positional number system
6
Principle of Information Technology (CST-1111)
Computer Codes
Numeric Data
- consists of only numbers 0, 1, 2, …, 9
Alphabetic Data
- consists of only the letters A, B, C,…, Z, in both uppercase and lowercase, and blank
character
Alphanumeric Data
- is a string of symbols where a symbol may be one of the letters A, B, C, …, Z, in either
uppercase or lowercase, or one of the digits 0,1, 2, …, 9, or a special character, such as + - * /
, . () = etc.
Computer codes
- are used for internal representation of data in computers
- As computers use binary numbers for internal data representation, computer codes use binary
coding schemes
- In binary coding, every symbol that appears in the data is represented by a group of bits
- The group of bits used to represent a symbol is called a byte.
- As most modern coding schemes use 8 bits to represent a symbol, the term byte is often used
to mean a group of 8 bits
Figure 4.1 shows BCD equivalent of each decimal digit. Since 8 and 9 require 4 bits, all decimal
digits are represented in BCD by 4 bits.
Converting 4210 is equal to 1010102
Converting 4210 into BCD result is 4210 = 0100 0010 or 01000010 in BCD
4 2
7
Principle of Information Technology (CST-1111)
Example4.1
Write the binary digits used to record the word BASE in BCD
Solution:
B = 110010 in BCD binary notation
A = 110001 in BCD binary notation
S = 010010 in BCD binary notation
E = 110101 in BCD binary notation
So the binary digits
110010 110001 010010 110101
B A S E
will record the word BASE in BCD
EBCDIC
EBCDIC stands for Extended Binary Coded Decimal Interchange Code. It uses 8 bits to
represent a symbol. It can represent 256(28) different characters.
8
Principle of Information Technology (CST-1111)
Example
Using binary notation, write EBCDIC coding for the word BIT. How many bytes are required for
this representation?
Solution:
B = 1100 0010 in EBCDIC binary notation
I = 1100 1001 in EBCDIC binary notation
T = 1110 0011 in EBCDIC binary notation
Hence, EBCDIC coding for the word BIT in binary notation will be
9
Principle of Information Technology (CST-1111)
ASCII
ASCII stands for American Standard Code for Information Interchange. ASCII is of two
types- ASCII-7 and ASCII-8. ASCII-7 uses 7 bits to represent a symbol and can represent 128(2 7)
different characters. ASCII-8 uses 8 bits to represent a symbol and can represent 256(2 8) different
characters. First 128 characters in ASCII-7 and ASCII-8 are same.
10
Principle of Information Technology (CST-1111)
Example
Write binary coding for the word BOY in AsCII-7. How many bytes are required for
this representation?
Solution:
Example
Write binary coding for the word SKY in AsCII-8. How many bytes are required for
this representation?
Solution:
Computer Arithmetic
Why Binary?
Almost all computers use binary numbers for internal computations because we can design
and implement electronic circuit for performing arithmetic operations in binary mode more easily,
reliably, and inexpensively than those required for performing arithmetic operations in decimal
mode.
Binary arithmetic is simple to learn as binary number system has only two digits : 0 and 1.
The followings are rules and example for the four basic arithmetic operations using binary numbers.
12
Principle of Information Technology (CST-1111)
1/ (carry)
111
110
11 01
Example (5.1)
Add binary numbers 10011 and 1001 in both decimal and binary form.
Solution
Binary Decimal
11 (carry) 1/ (carry)
10011 19
+1001 +9
11100 28
In this example, carry are generated for first and second columns
Example (5.2)
Add binary numbers 100111 and 11011 in both decimal and binary form.
Solution
Binary Decimal
11111 (carry) 1 (carry)
100111 39
+11011 +27
1000010 66
(1*2^6)+(1*2^1)=66
The addition of three 1s can be broken up into two steps.
First, we add only two 1s giving 10 (1 + 1 =10).
The third 1 is now added to this result to obtain 11 (a 1 sum with a 1 carry).
Hence, 1 + 1 + 1 =1, plus a carry of 1 to next higher column.
13
Principle of Information Technology (CST-1111)
Example (5.3)
Subtract 011102 from 101012
Solution
12
0202 (borrow)
10101
-01110
00111
Complement of a number
Example (5.4)
Find the complement of 3710
Solution
Since the number has 2 digits and the value of base is 10,
(Base)n - 1 = 102 - 1 = 99
Now 99 - 37 = 62
Hence, complement of 3710 = 6210
Example (5.5)
Find the complement of 68
Solution
Since the number has 1 digit and the value of base is 8,
(Base)n - 1 = 81 - 1 = 78
Now 78 - 68 = 18
Hence, complement of 68 = 18
Complement of 1 0 1 1 0 1 0 is
0 1 0 0 1 0 1
14
Principle of Information Technology (CST-1111)
Step 3: If there is a carry of 1, add it to obtain the result; if there is no carry, recomplement the sum
and attach a negative sign
Complementary subtraction is an additive approach of subtraction
Example (5.6)
Subtract 5610 from 9210 using complementary method.
Solution
Step 1: Complement of 5610 = 102 - 1 - 56 = 99 – 56 = 4310
Step 2: 92 + 43 = 135 (Here, 1 is carry.)
Step 3: Add carry 1 to sum: 35 + 1
Result = 36
The result may be verified using the method of normal subtraction: 92 - 56 = 36
Example (5.7)
Subtract 3510 from 1810 using complementary method.
Solution
Step 1: Complement of 3510 = 102 - 1 – 35 = 99 – 35 = 6410
Step 2: 18 +64 = 82
Step 3: Since there is no carry, re-complement the sum and attach a negative sign to obtain the result.
Result = -(99 - 82) = -17
The result may be verified using normal subtraction: 18 - 35 = -17
Example (5.8)
Subtract 01110002 (5610) from 10111002 (9210) using complementary method.
Solution
1011100
+1000111 (complement of 0111000)
10100011
1 (add the carry of 1)
0100100
Result = 01001002 = 3610
Example (5.9)
Subtract 1000112 (3510) from 0100102 (1810) using complementary method.
Solution
010010
+011100 (complement of 100011)
101110
Since there is no carry, we have to complement the sum and attach a negative sign to it. Hence,
Result = -0100012 (complement of 1011102)= -1710
15
Principle of Information Technology (CST-1111)
Example (5.10)
Multiply the binary numbers 1010 and 1001
Solution
1010 Multiplicand
x 1001 Multiplier
1010 Partial Product
0000x Partial Product
0000xx Partial Product
1010xxx Partial Product
1011010 Final Product
Whenever a 0 appears in the multiplier, a separate partial product consisting of a string of zeros need
not be generated (only a shift will do). Hence,
1010
x 1001
1010
1010xxx (left shift for 3 bits)
1011010
16
Principle of Information Technology (CST-1111)
5. Bring down the next digit to add to the remainder digits. Proceed as before in a manner similar to
long division
Example (5.11)
Divide 1000012 by 1102
Solution
0101 (Quotient)
110 100001 (Dividend)
0
1000
110
100
0
1001
110
11 (Remainder)
1 Divisor greater than 100, so put 0 in quotient
2 Add digit from dividend to group used above
3 Subtraction possible, so put 1 in quotient
4 Remainder from subtraction plus digit from dividend
5 Divisor greater, so put 0 in quotient
6 Add digit from dividend to group
7 Subtraction possible, so put 1 in quotient
Example (5.13)
Divide 3310 by 610 using the method of addition
Solution:
33 - 6 = 27
27 - 6 = 21
21 - 6 = 15
15 - 6 = 9
9-6=3
3 - 6 = -3
17
Principle of Information Technology (CST-1111)
Total subtractions = 6
Since the result of the last subtraction is less than zero,
Quotient = 6 - 1 (ignore last subtraction) = 5
Remainder = 3 (result of previous subtraction)
18