Digit Note
Digit Note
FOR
Course Code & Title: COM 112 INTRODUCTIO
N TO
DIGITAL ELECTRONICS
0 1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19
20 21 22 23 24 25 26 27 28 29
The table has 10 numbers across, which is the same number of symbols as the decimal system.
As you look at row 2, you notice that we added symbol 1 to the 0, making 10. In row 3, the one
is replaced by a 2, giving 20. The further you go down the table, the higher the numbers get.
The place values of different digits in a mixed decimal number, starting from the decimal point,
are 100, 101, 102 and so on (for the integer part) and 10-1, 10-2, 10-3 and so on (for the fractional
part). The value or magnitude of a given decimal number can be expressed as the sum of the
various digits multiplied by their place values or weights.
As an illustration, in the case of the decimal number 3586.265, the integer part (i.e., 3586) can
be expressed as
3586 = 6×100 + 8×101 + 5×102 + 3×103 = 6 + 80 + 500 + 3000 = 3586
and the fractional part can be expressed as
265 = 2×10−1 +6×10−2 +5×10−3 = 002+0006+00005 = 00265
We have seen that the place values are a function of the radix of the concerned number system
and the position of the digits.
Binary Number System
Binary is a number system used by digital devices like computers, cd players, etc. Binary is Base
2 unlike our counting system decimal which is Base 10 (denary). In other words, Binary has only
2 different numerals (0 and 1), unlike Decimal which has 10 numerals (0,1,2,3,4,5,6,7,8 and 9).
Here is an example of a binary number: 10011100
As you can see it is simply a bunch of zeroes and ones, there are 8 numerals in all which make
this an 8-bit binary number, bit is short for Binary Digit, and each numeral is classed as a bit.
The bit on the far right (in this case a zero) is known as the Least significant bit (LSB), and the bit
on the far left (in this case a 1) is known as the Most significant bit (MSB)
When writing binary numbers, you will need to signify that the number is binary (base 2), for
example take the value 101, as it is written it would be hard to work out whether it is a binary or
decimal (denary) value, to get around this problem it is common to denote the base to which
the number belongs by writing the base value with the number, for example:
1012 is a binary number and 10110 is a decimal (denary) value.
Octal Number System
The octal number system has a radix of 8 and therefore has eight distinct digits. All higher-order
numbers are expressed as a combination of these on the same pattern as the one followed in
the case of the binary and decimal number systems. The independent digits are 0, 1, 2, 3, 4, 5, 6
and 7. The next 10 numbers that follow ‘7’, for example, would be 10, 11, 12, 13, 14, 15, 16, 17,
20 and 21. In fact, if we omit all the numbers containing the digits 8 or 9, or both, from the
decimal number system, we end up with an octal number system. The place values for the
different digits in the octal number system are 80, 81, 82 and so on (for the integer part) and 8-1,
8-2, 8-3 and so on (for the fractional part).
Hexadecimal Number System
The hexadecimal number system is a radix-16 number system and its 16 basic digits are 0, 1, 2,
3, 4, 5, 6, 7, 8, 9, A, B, C, D, E and F. The place values or weights of different digits in a mixed
hexadecimal number are 160, 161, 162 and so on (for the integer part) and 16-1, 16-2, 16-3 and so
on (for the fractional part). The decimal equivalent of A, B, C, D, E and F are 10, 11, 12, 13, 14
and 15 respectively, for obvious reasons.
The hexadecimal number system provides a condensed way of representing large binary
numbers stored and processed inside the computer. One such example is in representing
addresses of different memory locations. Let us assume that a machine has 64K of memory.
Such a memory has 64K (= 216 = 65 536) memory locations and needs 65 536 different
addresses. These addresses can be designated as 0 to 65 535 in the decimal number system and
00000000 00000000 to 11111111 11111111 in the binary number system. The decimal number
system is not used in computers and the binary notation here appears too cumbersome and
inconvenient to handle. In the hexadecimal number system, 65 536 different addresses can be
expressed with four digits from 0000 to FFFF. Similarly, the contents of the memory when
represented in hexadecimal form are very convenient to handle. Here are the digits used in
hexadecimal and their equivalents in binary and decimal:
Hex 0 1 2 3 4 5 6 7 8 9 A B C D E F
Decimal 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Binary 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111
Week 2
Objective:
Understand Number Systems
Conversion from Binary, Octal and Hexadecimal to Decimal & Decimal to Binary, Octal and
Hexadecimal
Conversion from Binary to Octal & Octal to Binary
Conversion from Binary to Hexadecimal & Hexadecimal to Binary
Binary, Octal and Hexadecimal to Decimal
The decimal equivalent of a given number in another number system is given by the sum of all
the digits multiplied by their respective place values. The integer and fractional parts of the
given number should be treated separately. Binary-to-decimal, octal-to-decimal and
hexadecimal-to-decimal conversions are illustrated below with the help of examples.
Binary-to-Decimal Conversion
The decimal equivalent of the binary number (1001.0101)2 is determined as follows:
• Therefore, the decimal equivalent = 0 × 2-1 + 1 × 2-2 + 0 × 2-3 + 1 × 2-4 = 0 + 0.25 + 0 + 0.0625 = 0.3125
Octal-to-Decimal Conversion
The decimal equivalent of the octal number (137.21)8 is determined as follows:
Hexadecimal-to-Decimal Conversion
The decimal equivalent of the hexadecimal number (1E0.2A)16 is determined as follows:
• The integer part = 1E0
• The decimal equivalent = 0 × 160 + 14 × 161 + 1 × 162 = 0 + 224 + 256 = 480
• The fractional part = 2A
• The decimal equivalent = 2 × 16-1 + 10 × 16-2 = 0.164
• Therefore, the decimal equivalent of (1E0.2A)16 = (480.164)10
2 13 —
2 6 1
2 3 0
2 1 1
— 0 1
7 111
Binary–Octal and Octal–Binary Conversions
An octal number can be converted into its binary equivalent by replacing each octal digit with its
three-bit binary equivalent. We take the three-bit equivalent because the base of the octal
number system is 8 and it is the third power of the base of the binary number system, i.e. 2. All
we have then to remember is the three-bit binary equivalents of the basic digits of the octal
number system. A binary number can be converted into an equivalent octal number by splitting
the integer and fractional parts into groups of three bits, starting from the binary point on both
sides. The 0s can be added to complete the outside groups if needed.
Example
Let us find the binary equivalent of (374.26)8 and the octal equivalent of (1110100.0100111)2
Solution
The given octal number = (374.26)8
The binary equivalent = (011 111 100.010 110)2= (011111100.010110)2
Any 0s on the extreme left of the integer part and extreme right of the fractional part of the
equivalent binary number should be omitted. Therefore, (011111100.010110) 2=
(11111100.01011)2
The given binary number = (1110100.0100111)2
(1110100.0100111)2 = (1 110 100.010 011 1)2
= (001 110 100.010 011 100)2 = (164.234)8
Hex–Binary and Binary–Hex Conversions
A hexadecimal number can be converted into its binary equivalent by replacing each hex digit
with its four-bit binary equivalent. We take the four-bit equivalent because the base of the
hexadecimal number system is 16 and it is the fourth power of the base of the binary number
system. All we have then to remember is the four-bit binary equivalents of the basic digits of the
hexadecimal number system. A given binary number can be converted into an equivalent
hexadecimal number by splitting the integer and fractional parts into groups of four bits,
starting from the binary point on both sides. The 0s can be added to complete the outside
groups if needed.
Example 1.7
Let us find the binary equivalent of (17E.F6)16 and the hex equivalent of
(1011001110.011011101)2.
Solution
The given hex number = (17E.F6)16
The binary equivalent = (0001 0111 1110.1111 0110)2
= (000101111110.11110110)2
= (101111110.1111011)2
The 0s on the extreme left of the integer part and on the extreme right of the fractional part
have been omitted.
The given binary number = (1011001110.011011101)2
= (10 1100 1110.0110 1110 1)2
The hex equivalent = (0010 1100 1110.0110 1110 1000) 2 = (2CE.6E8)16
Hex–Octal and Octal–Hex Conversions
For hexadecimal–octal conversion, the given hex number is firstly converted into its binary
equivalent which is further converted into its octal equivalent. An alternative approach is firstly
to convert the given hexadecimal number into its decimal equivalent and then convert the
decimal number into an equivalent octal number. The former method is definitely more
convenient and straightforward. For octal–hexadecimal conversion, the octal number may first
be converted into an equivalent binary number and then the binary number transformed into
its hex equivalent. The other option is firstly to convert the given octal number into its decimal
equivalent and then convert the decimal number into its hex equivalent. The former approach is
definitely the preferred one. Two types of conversion are illustrated in the following example.
Example
Let us find the octal equivalent of (2F.C4)16 and the hex equivalent of (762.013)8
Solution
The given hex number = (2F.C4)16.
The binary equivalent = (0010 1111.1100 0100)2 = (00101111.11000100)2
= (101111.110001)2 = (101 111.110 001)2 = (57.61)8.
The given octal number = (762.013)8.
The octal number = (762.013)8 = (111 110 010.000 001 011)2
= (111110010.000001011)2
= (0001 1111 0010.0000 0101 1000)2 = (1F2.058) 16.
The Four Axioms
Conversion of a given number in one number system to its equivalent in another system has
been discussed at length in the preceding sections. The methodology has been illustrated with
solved examples. The complete methodology can be summarized as four axioms or principles,
which, if understood properly, would make it possible to solve any problem related to
conversion of a given number in one number system to its equivalent in another number
system. These principles are as follows:
1. Whenever it is desired to find the decimal equivalent of a given number in another number
system, it is given by the sum of all the digits multiplied by their weights or place values. The
integer and fractional parts should be handled separately. Starting from the radix point, the
weights of different digits are r0, r1, r2 for the integer part and r-1, r-2, r-3 for the fractional part,
where r is the radix of the number system whose decimal equivalent needs to be determined.
2. To convert a given mixed decimal number into an equivalent in another number system, the
integer part is progressively divided by r and the remainders noted until the result of division
yields a zero quotient. The remainders written in reverse order constitute the equivalent. r is the
radix of the transformed number system. The fractional part is progressively multiplied by r and
the carry recorded until the result of multiplication yields a zero or when the desired number of
bits has been obtained. The carrys written in forward order constitute the equivalent of the
fractional part.
3. The octal–binary conversion and the reverse process are straightforward. For octal–binary
conversion, replace each digit in the octal number with its three-bit binary equivalent. For
hexadecimal–binary conversion, replace each hex digit with its four-bit binary equivalent. For
binary–octal conversion, split the binary number into groups of three bits, starting from the
binary point, and, if needed, complete the outside groups by adding 0s, and then write the octal
equivalent of these three-bit groups. For binary–hex conversion, split the binary number into
groups of four bits, starting from the binary point, and, if needed, complete the outside groups
by adding 0s, and then write the hex equivalent of the four-bit groups.
4. For octal–hexadecimal conversion, we can go from the given octal number to its binary
equivalent and then from the binary equivalent to its hex counterpart. For hexadecimal–octal
conversion, we can go from the hex to its binary equivalent and then from the binary number to
its octal equivalent.
Exercise : Convert the following binary numbers to hex and oct
Q1. 102
Q2. 10112
Q3. 1011112
Q4. 00112
Q5. 110011
Binary Addition
Binary addition is very simple. This is best shown in an example of adding two binary numbers…
1111012 +101112
1 1 1 1 1 1 carries
1 1 1 1 0 1
+ 1 0 1 1 1
1 0 1 0 1 0 0
Binary Subtraction
We can also perform subtraction (with borrows in place of carries).
Let’s subtract (10111)2 from (1001101)2