2. Number System
A number system is a code that uses symbols to refer to
a number of items.
This number system, which is more familiar to us, is
the decimal number system.
It uses the Symbols 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9.
The decimal number system contains symbols and it is
also called the base-10 number system.
3. Binary Number System:
The binary number system uses only two symbols 0 and 1; and it
is sometimes called base-2 number system. As in the case of
decimal system, the significance of bits in a binary system is
determined by their position in that number. For example, the
binary number 110 can be written as
(1 x 22) + (1 x 21) + (0 x 20)
and thus has the decimal number value 4+2+0=6
It is just like the decimal system as for 165 can be written as
(1 x 102) + (6 x 101) + (5 x 100) = 100 + 60 + 5 = 165
4. Binary Number System:
In a binary number fraction part can be represented by
using a negative sign with the bit position to the right
of the binary point. For example, the binary number
101.110 can be written in the expanded form as
(1x22)+(0x21)+(1x20)+(1x2-1)+(1x2-2)+(0x2-3)
and thus has the decimal number value
4 + 0 + 1 + 0.50 + 0.25 + 0 = 5.75
5. Octal Number System:
The octal number system is a base-8 system and makes use of the eight digits 0, 1, 2, 3, 4,
5, 6, and 7. At the primary stage of the development of modern computer the octal
number system was used. In an octal number system, such as 703, the digits represent
coefficients of powers of 8 and the number therefore can be written in the expanded
form as
(7 x 82) + (0 x 81) + (3 x 80)
and thus the decimal number value
448 + 0 + 3 = 451
Similarly the fraction of the octal number 7.2 can be written in the expanded form as
(7 x 80) + (2 x 8-1)
and thus the decimal number value
7 + 0.25 = 7.25
6. Hexadecimal Number System:
The hexadecimal number system is a base-16 system and makes use of the sixteen digits
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A or a (10), B or b (11), C or c (12), D or d (13), E or e (14), and F or f
(16). In an hexadecimal number such as 1Ab, the digits represent coefficients of powers of
16 and the number therefore can be written as in the expanded form as
(1 x 162) + (10 x 161) + (11 x 160)
and thus the decimal number value
256 + 160 + 11 = 427
Similarly, the fraction of the hexadecimal number 8.c can be written in the expanded
form as
(8 x 160) + (12 x 16-1)
and thus the decimal number value
8 + 0.75 = 8.75
7. Comparisons of different number
systems.
Number System Base Digits Used Examples
Binary 2 0 1 110, 10, 100.01
Octal 8 0 1 2 3 4 5 6 7 567, 12.57, 0.12
Decimal 10 0 1 2 3 4 5 6 7 8 9 100, 999, 10.79
Hexadecimal 16 0 1 2 3 4 5 6 7 8 9 A B C D E F AIB, ABC, 10.D
8. Conversion of a base-10 number to
its base-b equivalent:
In order to find the base b equivalent of a base-10 whole number, the
number is divided repeatedly by b until a quotient of zero results. The
successive remainders are the digits from right to left of the base-b
representation. On the hand, to convert a decimal number with a
fractional part to its base-b equivalent, the fractional part of the
number is repeatedly multiplied by b until the fractional part reduces
to zero. The integer parts are the digits from left to right of the base-b
representation. It may be noted that even though the base-10
representation of a fraction may be terminate, its representation in
some other base need not terminate. The left-most digit of any base
number system is called the Most Significant Bit (MSB), and the right-
most digit is called the Least Significant Bit (LSB). Now we discuss
some examples.
9. Decimal to Binary:
Example 1: Convert a decimal number 21.25 to its binary, octal, and hexadecimal equivalents
Solutions: It has two parts: Integer part=21 and fractional part=25.
For integer part 21
21/2 = 10 remainder=1 LSB
10/2 = 5 remainder=0
5/2 = 2 remainder=1
2/2 =1 remainder=0
½ =0 remainder=1 MSB
So the binary equivalent of (21)10=(10101)2
Now for 0.25
0.25x2 =0.50 Integer part=0 MSB
0.50x2 =1.0 Integer Part=1 LSB
So, the binary equivalent of (0.25)10 is (0.01)2
The final binary equivalent of (21.25)10 is (10101.01)2
10. Decimal to Octal:
For integer part 21
21/8= 2 remainder=5 LSB
2/8 = 0 remainder=2 MSB
So the octal equivalent of (21)10=(25)8
Now for 0.25
0.25x8 =2.0 Integer part=2 MSB/LSB
So, the octal equivalent of (0.25)10 is (0.2)8
The final octal equivalent of (21.25)10 is (25.2)8
11. Decimal to Hexadecimal:
For integer part 21
21/16= 1 remainder=5 LSB
1/16 = 0 remainder=1 MSB
So the hexadecimal equivalent of (21)10=(15)16
Now for 0.25
0.25x16 =4.0 Integer part=4 MSB/LSB
So, the hexadecimal equivalent of (0.25)10 is (0.4)16
The final hexadecimal equivalent of (21.25)10 is (15.4)16
12. Decimal to Hexadecimal Continue:
Example 2: Convert a decimal number 221.3 to its hexadecimal equivalents
Solutions: It has two parts: Integer part=221 and fractional part=3.
For integer part 221
221/16= 13 remainder=13 (D) LSB
13/16 = 0 remainder=13 (D) MSB
So the hexadecimal equivalent of (221)10=(DD)16
Now for 0.3
0.3x16 =4.8 Integer part =4 MSB
0.8x16 =12.8 Integer part =12 (C)
0.8x16 =12.8 Integer part =12 (C) LSB
So, the hexadecimal equivalent of (0.3)10 is (0.4CC)16
The final hexadecimal equivalent of (221.3)10 is (DD.4CC)16
13. Binary to Decimal:
Say (N)2 is a base-2 (Binary) number, where
(N)2 = (am am-1 am-2…a0.a-1 a-2..a-n)
here, there are (m+1) integer digits and n fractional digits in the number. Then
the base-10 equivalent to the number (N)2 is given by the following equations.
(N)10 = am2m+am-12m-1+am-22m-2+….+a020+a-12-1+a-22-2+…..+a-n2-n
Example 7: Convert (1011.101)2 to its decimal equivalent
Solutions: The decimal number is = 1x23 + 0x22 + 1x21 +1x20 +1x2-1 +
0x2-2 + 1x2-3
= 8 + 0+2 + 1 + 0.5+0.25+0.125
= 11.875
14. Octal to Decimal:
Say (N)8 is a base-8 number, where
(N)8 = (am am-1 am-2…a0.a-1 a-2..a-n)
here, there are (m+1) integer digits and n fractional digits in the
number. Then the base-10 equivalent to the number (N)8 is given by the
following equations.
(N)10 = am8m+am-18m-1+am-28m-2+….+a080+a-18-1+a-28-2+…..+a-n8-n
Example 7: Convert (716.23)8 to its decimal equivalent
Solutions: The decimal number is
= 7x82 + 1x81 + 6x80 + 2x8-1 + 3x8-2
= 448 + 8 + 6 + 0.25 + 0.04687
= 462.29687
15. Hexadecimal to Decimal:
Say (N)16 is a base-16 number, where
(N)16 = (am am-1 am-2…a0.a-1 a-2..a-n)
here, there are (m+1) integer digits and n fractional digits in the
number. Then the base-10 equivalent to the number (N)16 is given by
the following equations.
(N)10 = am16m+am-116m-1+am-216m-2+….+a0160+a-116-1+a-216-2+…..+a-n16-n
Example 3: Convert (ABC.0F)16 to its decimal equivalent
Solutions: The decimal number is
= 10x162 + 11x161 + 12x160 + 0x16-1 + 15x16-2
= 2560 + 176 + 12 + 0 + 0.05859
= 2748.05859
16. Binary to Octal:
Group integer part of the binary number in groups of three bits from right to
left, add extra zero to the left if needed. Group fraction part of the binary
number in groups of three bits from left to right, add extra zero to the right if
needed. Then convert each group to its octal equivalent.
Example 9: Convert (1011)2, (00011010)2, (011111010100)2, (10001010.0010)2 to its
octal equivalent.
Solutions:
(1011)2 = (001 011)2 = (13)8
(00011010)2 = (000 011 010)2 = (032)8
(011111010100)2 = (011 111 010 100)2 = (3724)8
(10001010.0010)2 = (010 001 010 . 001 000)2 = (212.10)8
17. Octal to Binary:
We can easily convert octal number to binary by
replacing each octal digit by its binary equivalent.
Example 8: Convert (712)8, (14.6)8, (11.11)8 to it
equivalent Binary number.
Solutions:
(712)8 = (111001010)2
(14.6)8 = (001100.110)2
(11.11)8 = (001001.001001)2
18. Binary to Hexadecimal:
Group integer part of the binary number in groups of four bits from right to
left, add extra zero to the left if needed. Group fraction part of the binary
number in groups of four bits from left to right, add extra zero to the right if
needed. Then convert each group to its hexadecimal equivalent.
Example 9: Convert (001011)2, (011010)2, (011111010100)2, (010001010.001000)2 to
its hexadecimal equivalent.
Solutions:
(001011)2 = (0000 1011)2 =(0B)16
(011010)2 = (0001 1010)2 =(1A)16
(011111010100)2 = (0111 1101 0100)2 =(7D4)16
(010001010.001000)2 = (1000 1010 . 0010)2 =(8A.2)16
19. Hexadecimal to Binary:
We can easily convert hexadecimal number to binary by
replacing each hexadecimal digit by its binary equivalent.
Example 5: Convert (B12)16, (1A.D)16, (11.11)16 to it equivalent
Binary number.
Solutions:
(B12)16 = (101100010010)2
(1A.D)16 = (00011010.1101)2
(11.11)16 = (00010001.00010001)2
20. Octal to Hexadecimal:
We can convert it first to its equivalent decimal number and then the decimal number to
its equivalent hexadecimal number. This is time consuming method. Another method,
which is frequently used, is given below.
The octal number is first converted to its binary equivalent. Then for integer part, we
group binary digits in groups of four bits from right to left. We can add extra zero to the
left if needed. And for the fractional part, group bits from left to right, add extra zero to
the right if needed. Then convert each group to its hexadecimal equivalent.
Example 6: Convert (13)8, (32)8, (3724)8, (212.10)8 to it equivalent hexadecimal number.
Solutions:
(13)8 = (001011)2 = (0000 1011)2 =(0B)16
(32)8 = (011010)2 = (0001 1010)2 =(1A)16
(3724)8 = (011111010100)2 = (0111 1101 0100)2 =(7D4)16
(212.10)8 = (010001010.001000)2 = (1000 1010 . 0010)2 =(8A.2)16
22. Binary Addition:
Binary addition is exactly same as decimal addition except that the rules are
much simpler.
Binary rules are:
0 + 0 = 0
0 + 1 = 1
1 + 0 = 1
1 + 1 = 0 and a carry of 1
Example 1: Add 101010 with 111111 101010 42
+111111 63
1101001 105
Example 2: Add 1010 with 110 1010 10
+110 +6
10000 16
23. Binary Subtraction:
In decimal subtraction, we subtract decimal digit from a smaller digit by
borrowing 1 from the next column. This is also true for binary subtraction. But
there is an easy method for binary subtraction. Here, subtraction is done
through addition. To subtract using addition, we use 1’s or 2’s complement of
the subtrahend (number to be subtracted).
The 1’s complement is produced from any binary number by just inverting each
digit (1 becomes 0, and 0 becomes 1). For example, 1’s complement of the
binary number 1101 is 0010.
The 2’s complement of any binary number is produced by taking 1’s
complement and then adding a 1. For example, the 1’s complement of 11001 is
00110, and then the 2’s complement is (00110+1)=00111.
24. Subtraction by 1’s complement:
Find the 1’s complement of the number to be subtracted.
Add it to the number from which it has to be subtracted.
If there is a carry of 1, add it to obtain the result. If there is no carry, the result is negative.
To get the result take 1’s complement again of the sum, attach a minus sign.
Example 1: Subtract 011 from 110 using 1’s complement method.
1’s complement of 011 is 100
To subtract, add it to 110, and get
110
+100
1010
There is a carry of 1. So, add the carry to get the result.
010 + 1 = 011 (Ans).
To prove the correctness tries to subtract converting the numbers into decimal.
25. Example 2: Subtract 1100 from 1010 using 1’s complement method.
1’s complement of 1100 is 0011.
To subtract, add it to 1010, and get
1010
+0011
1101
There is no carry, so result is negative. To get the result, take 1’s
complement of 1101 to get 0010. So the answer is -0010.
To prove the correctness tries to subtract converting the numbers into
decimal.
26. Subtraction by 2’s Complement:
Find the 2’s complement of the number to be subtracted.
Add it to the number from which it has to be subtracted.
If there is a carry of 1, just drop the carry to get the result. If there is no carry, find 2’s
complement and attach a negative sign to obtain the result.
Example 1: Subtract 011 from 110 using 2’s complement method.
1’s complement of 011 is 100. 2’s complement is 100 + 1 = 101.
To subtract, add it to 110, and get
110
+101
1011
There is a carry of 1. Ignore the carry, so the result is = 011 (Ans).
To prove the correctness tries to subtract converting the numbers into decimal.
27. Subtraction by 2’s Complement
Example 2: Subtract 1100 from 1010 using 2’s complement method.
1’s complement of 1100 is 0011. 2’s complement is 0011 + 1 = 0100
To subtract, add it to 1010, and get
1010
+0100
1110
There is no carry, so result is negative. To get the result, take 2’s
complement of 1110 to get 0010. So the answer is -0010.
To prove the correctness tries to subtract converting the numbers into decimal.
28. ASCII code
ASCII (American Standard Code for Information
Interchange) is a character encoding scheme.
Originally based on the English alphabet that encodes 128
specified characters.
128 characters includes- the numbers 0-9, the letters a-z
and A-Z, some punctuation symbols, some control codes
and a blank space.
The standard ASCII uses 7-bit for each character
29. ASCII code
Another version of ASCII uses 8-bit code which gives
128 additional characters.
These extra characters are used to represent non-
English characters, graphics symbols, and
mathematical symbols.
Some examples are given on the next slide:
30. ASCII Code
Binary Decimal Symbol Binary Decimal Symbol
0110000 48 0 1100001 97 a
0110001 49 1 1100010 98 b
0111001 57 9 1111010 122 Z
1000001 65 A 0001101 13 CR (Enter)
1000010 66 B 0111100 60 <
1011010 90 Z 0011011 27 ESC
0000000 0 NULL 1111111 127 DEL
31. Unicode
Unlike ASCII, Unicode uses 16 bits.
So it can represent more than 65000 unique
characters( Exactly 216=65536).
All the language’s characters of the world are
represented by Unicode.