Module1 Notes - Number Systems
Module1 Notes - Number Systems
Module1 Notes - Number Systems
Introduction
The term digital, is derived from the way computers perform operations, by counting digits.
Today, digital technology is applied in a wide range of areas in addition to computers. Such
applications as television, communications systems, radar, navigation and guidance systems,
military systems, medical instrumentation, industrial process control, and consumer electronics
use digital techniques.
Electronic circuits can be divided into two broad categories, digital and analog. Digital
electronics involves quantities with discrete values, and analog electronics involves quantities
with continuous values.
Digital electronics involves circuits and systems in which there are only two possible states.
These states are represented by two different voltage levels: A HIGH and a LOW. The two-state
number system is called binary, and its two digits are 0 and 1. A binary digit is called a bit.
Module 1
Number Systems:
A number system is a collection of various symbols which are called digits. Different types
of Number Systems are there:
For example:
843 = 8 x 10 2 + 4 x 101 + 3 x 100
= 8 x 100 + 4 x 10 + 3 x 1
= 800 + 40 + 3
Faculty: Asst. Prof. Rani Augustine IT Department, TIST
IT 201 Digital System Design
For whole numbers, the rightmost digit position is the one’s position (10 0 = 1). The
numeral in that position indicates how many ones are present in the number. The next
position to the left is ten’s, then hundred’s, thousand’s, and so on. Each digit position has
a weight that is ten times the weight of the position to its right.
In the decimal number system, there are ten possible values that can appear in each
digit position, and so there are ten numerals required to represent the quantity in each
digit position. The decimal numerals are the familiar zero through nine (0, 1, 2, 3, 4, 5,
6, 7, 8, 9).
In a positional notation system, the number base is called the radix. Thus, the base ten
system that we normally use has a radix of 10. The term radix and base can be used
interchangeably. When writing numbers in a radix other than ten, or where the radix
isn’t clear from the context, it is customary to specify the radix using a subscript.
2. Binary Numbers
The binary number system is also a positional notation numbering system, but in this
case, the base is two. Each digit position in a binary number represents a power of two.
So, when we write a binary number, each binary digit is multiplied by an appropriate
power of 2 based on the position in the number:
For example:
101101 = 1 x 2 5 + 0 x 2 4 + 1 x 23 + 1 x 22 + 0 x 21 + 1 x 20
= 1 x 32 + 0 x 16 + 1 x 8 + 1 x 4 + 0 x 2 + 1 x 1
= 32 + 8 + 4 + 1
= 45
In the binary number system, there are only two possible values that can appear in each
digit position rather than the ten that can appear in a decimal number. Only the numerals
0 and 1 are used in binary numbers. The term ‘bit’ is a contraction of the words ‘binary’
and ‘digit’, and when talking about binary numbers the terms bit and digit can be used
interchangeably. When talking about binary numbers, it is often necessary to talk of the
number of bits used to store or represent the number. This merely describes the number
of binary digits that would be required to write the number. The number in the above
example is a 6 bit number.
10110
\ ______________1 x 21 = 2
\________________1 x 22 = 4
\___________________1 x 24 = 16
22
Another convert 110112 to
example: decimal
11011
\ __________1 x 20 = 1
\___________1 x 21 = 2
\______________1 x 23 = 8
\_______________1 x 24 = 16
27
The method for converting a decimal number to binary is one that can be used to convert
from decimal to any number base. It involves using successive division by the radix until
Faculty: Asst. Prof. Rani Augustine IT Department, TIST
IT 201 Digital System Design
the dividend reaches 0. At each division, the remainder provides a digit of the converted
number, starting with the least significant digit.
convert 3710 to
An example of the process: binary
37 / 2 = 18 remainder 1 (least significant digit)
18 / 2 = 9 remainder 0
9/ 2 = 4 remainder 1
4/ 2 = 2 remainder 0
2/ 2 = 1 remainder 0
1/ 2 = 0 remainder 1 (most significant digit)
The resulting binary number is: 100101
convert 9310 to
Another example: binary
93 / 2 = 46 remainder 1 (least significant digit)
46 / 2 = 23 remainder 0
23 / 2 = 11 remainder 1
11 / 2 =5 remainder 1
5 /2 =2 remainder 1
2 /2 =1 remainder 0
1 /2 =0 remainder 1 (most significant digit)
Exercises
1. Convert the following binary numbers to decimal
a. 1001012 = ----10:
2
Exponents 2 5 24 23 22 21 0
Place Values 32 16 8 4 2 1
Bits 1 0 0 1 0 1
Value 32 + 4 + 1 = 37
Ans= 3710
b. 1111010002 = ____10:
2
Exponents 28 27 26 25 2 4 2 3 22 21 0
Ans: 48810
c. 100011102 = 14210:
d. 101101012 = 18110:
Exponents 27 26 25 2 4 2 3 22 21 1
Place Values 128 64 32 16 8 4 2 1
Bits 1 0 1 1 0 1 0 1
Value 128 + 32 + 16 + 4 + 1 = 181
2. Convert the decimal numbers to their binary equivalents:
(a) 256
Solution:
256
Since the given number 256 appears in the first row, we put 1 in the slot below 256 and fill all
the other slots to the right of this slot with zeros.
(b) 77
Solution:
77
The given number is less than 128 but greater than 64. We therefore put 1 in the slot
corresponding to 64 in the first row. Next, we subtract 64 from 77 and get 13 as remainder.
This remainder is less than 16 and greater than 8. So we put 1 in the slot corresponding to 8 and
subtract 8 from 13. This gives 13 - 8 = 5. This remainder is greater than 4 and less than 8.
Hence we put 1 in the slot corresponding to 4 and subtracting 4 from 5 we get 1. Now, 1 is
present in the right hand most slot of the first row. We, therefore, put 1 in the corresponding slot
and fill all other slots with zeros.
Solution:
Subtract .5 from the given number to get .675 - .5 = .175 and place 1 in the slot corresponding to
.5 of the first row.
Now the number .175 is less than .25 and greater than .125. So, we put 1 in the slot
corresponding to the number .125 of the first row and subtract .125 from .175 to get .175 - .125 =
.05. The remainder .05 is less than .0625 but greater than .03125.
Hence we put 1 in the slot corresponding to 0.3125 and the subtraction given .05 - .03125 =
.01875 and continue the process. The other slots are then filled with zeros.
Solution:
(a) 0.375
Solution:
Faculty: Asst. Prof. Rani Augustine IT Department, TIST
IT 201 Digital System Design
Solution:
Fox mixed number, we will have to separate the number into its integral and fractional parts and
find the binary equivalent of each part independently.
Finally, we add the two parts to get the binary equivalent of the given number.
Solution:
0.75 × 2 = 1.5 1 .5
0.5 × 2 = 1.0 1 0
3. Hexadecimal Numbers
In addition to binary, another number base that is commonly used in digital systems is
base 16. This number system is called hexadecimal, and each digit position represents a
power of 16. For any number base greater than ten, a problem occurs because there are
more than ten symbols needed to represent the numerals for that number base. It is
customary in these cases to use the ten decimal numerals followed by the letters of the
alphabet beginning with A to provide the needed numerals. Since the hexadecimal
system is base 16, there are sixteen numerals required. The following are the
hexadecimal numerals:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
The reason for the common use of hexadecimal numbers is the relationship between the
numbers 2 and 16. Sixteen is a power of 2 (16 = 2 4). Because of this relationship, four
digits in a binary number can be represented with a single hexadecimal digit. This makes
conversion between binary and hexadecimal numbers very easy, and hexadecimal can be
used to write large binary numbers with much fewer digits. When working with large
digital systems, such as computers, it is common to find binary numbers with 8, 16 and
even 32 digits. Writing a 16 or 32 bit binary number would be quite tedious and error
prone. By using hexadecimal, the numbers can be written with fewer digits.
To convert a binary number to hexadecimal, divide it into groups of four digits starting
with the rightmost digit. If the number of digits isn’t a multiple of 4, prefix the number
with 0’s so that each group contains 4 digits. For each four digit group, convert the 4 bit
binary number into an equivalent hexadecimal digit. (See the Binary, BCD, and
Hexadecimal Number Tables at the end of this document for the correspondence between
4 bit binary patterns and hexadecimal digits)
3 7 4 F
Convert the hex digits to binary 0011 0111 0100 1111
00110111010011112
There are several ways in common use to specify that a given number is in hexadecimal
representation rather than some other radix. In most programming languages, this method
isn’t really feasible, so there are several conventions used depending on the language. In
the C and C++ languages, hexadecimal constants are represented with a ‘0x’ preceding
the number, as in: 0x317F, or 0x1234, or 0xAF. The letter ‘h’ is then suffixed onto the
number to inform the assembler that it is a hexadecimal constant. In Intel style assembler
format: 371Fh and 0FABCh are valid hexadecimal constants.
4. OCTAL NUMBERS
Like the hexadecimal number system, the octal number system provides a convenient way to
express binary numbers and codes. The octal number system is composed of eight digits, which
are 0, 1, 2, 3, 4, 5, 6, 7
To count above 7, begin another column and start over:
Octal-to-Decimal Conversion
Since the octal number system has a base of eight, each successive digit position is an increasing
power of eight, beginning in the right-most column with 8°. The evaluation of an octal number in
terms of its decimal equivalent is accomplished by multiplying each digit by its weight and
summing the products, as illustrated here for 2374 8.
Decimal-to-Octal Conversion
A method of converting a decimal number to an octal number is the repeated division-by- 8
method, which is similar to the method used in the conversion of decimal numbers to binary
or to hexadecimal. To show how it works, let's convert the decimal number 359 to octal. Each
successive division by 8 yields a remainder that becomes a digit in the equivalent octal number.
The first remainder generated is the least significant digit (LSD).
Octal-to-Binary Conversion
Because each octal digit can be represented by a 3-bit binary number, it is very easy to convert
from octal to binary. Each octal digit is represented by three bits as shown in Table
To convert an octal number to a binary number, simply replace each octal digit with the
appropriate three bits.
Binary-to-Octal Conversion
Conversion of a binary number to an octal number is the reverse of the octal-to-binary
conversion. The procedure is as follows: Start with the right-most group of three bits and,
moving from right to left, convert each 3-bit group to the equivalent octal digit. If there are not
three bits available for the left-most group, add either one or two zeros to make a complete
group. These leading zeros do not affect the value of the binary number.
Conversion Table
Decimal Binary Octal 3-bit String Hexa-decimal 4-bit String
0 0 0 000 0 0000
1 1 1 001 1 0001
2 10 2 010 2 0010
3 11 3 011 3 0011
8 1000 10 - 8 1000
9 1001 11 - 9 1001
10 1010 12 - A 1010
11 1011 13 - B 1011
12 1100 14 - C 1100
13 1101 15 - D 1101
14 1110 16 - E 1110
15 1111 17 - F 1111
(a) 11101011102
Solution:
001110101110
= 16568
(b) 111101.011012
Solution:
111101.0110102
= 75.328
(a) 15738
Solution:
15738
= 11011110112
(b) 64.1758
Solution:
64.1758
= 110100.0011111012
(a) 11111011012
Solution:
001111101101
= 3ED16
(b) 11110.010112
Solution:
11110.010112
= 1E.5816
(a) A74816
Solution:
A74816
= 10100111010010002
(b) BA2.23C16
Solution:
BA2.23C16
= 101110100010.0010001111
Solution:
15738
= 001101111011
Solution:
A74816
= 1235108
(a) 7258
Solution:
7258 = 111010101
= 256 + 128 + 64 + 16 + 4 + 1
= 46910
(b) D9F16
Solution:
D9F16
= 110110011111
= 348710
BINARY ARITHMETIC
Binary addition
Binary addition is performed in the same manner as decimal addition.
0+0=0
0+1=1
1+0=1
1 + 1 = 0 with a carry-over of 1
Solution:
10101
11011
110000
Solution:
11001
111
100000
Solution:
11 11 11 Carry overs
10101.101
1101.011
100011.000
Solution:
111.0111
10011.001
11010.1001
Binary subtraction
The rules of binary subtraction are as
follows:
0-0=0
1-0=1
1-1=0
0 - 1 = 1 with a borrow of 1
1 Borrow
1001
101
100
Solution:
1 Borrow
1000
111
0001
Solution:
1 Borrow
1111011.11
1010101.10
100110.01
Solution:
1 1 1 Borrow
101100.011
11010.101
10001.110
Binary Multiplication
× 1 0
1 1 0
0 0 0
Multiply:
10111
1101
10111
10111
11011.101
101.111
11011.101
1101110 1
11011101
11011101
10100010010 011
Binary Division
Evaluate:
Solution:
Solution:
Solution:
Thus the quotient is 1.101 upto 3 places of binary point and the remainder is
1.011.
Solution:
Thus the quotient is 0.11 upto 2 places of binary point and the remainder is
0.1.
? Compare 1’s and 2’s complement methods of representations[KTU April 2018- 4 marks]
The 1’s complement and the 2’s complement of a binary number are important because they
permit the representation of negative numbers. The method of 2’s complement arithmetic is
commonly used in computers to handle negative numbers.
The 1’s complement of a binary number is found by changing all 1s to 0s and all 0s to 1s as
shown below:
SIGNED NUMBERS
Explain how to represent negative numbers in digital system? [KTU- Jan 2018]
Digital systems, such as the computer, must be able to handle both positive and negative
numbers. A signed binary number consists of both sign and magnitude information. The
sign indicates whether a number is positive or negative, and the magnitude is the value
of the number. There are three forms in which signed integer (whole) numbers can be
represented in binary: sign-magnitude, l’s complement, and 2’s complement.
Floating-Point Numbers
To represent very large integer (whole) numbers, many bits are required. There is also a
problem when numbers with both integer and fractional parts, such as 23.5618, need to be
represented. The floating-point number system, based on scientific notation, is capable of
representing very large and very small numbers without an increase in the number of bits
and also for representing numbers that have both integer and fractional components.
A floating-point number (also known as a real number) consists of two parts plus a
sign. The mantissa is the part of a floating-point number that represents the magnitude of the
number. The exponent is the part of a floating-point number that represents the number
of places that the decimal point (or binary point) is to be moved.
Let’s consider a decimal number which, in integer form, is 241,506,800. The mantissa is
.2415068 and the exponent is 9. When the integer is expressed as a floating point number, it is
normalized by moving the decimal point to the left of all the digits so that the mantissa is a
fractional number and the exponent is the power of ten. The floating point number is written as
0.2415068 x 109
Single-Precision Floating-Point Binary Numbers In the standard format for a single precision
binary number, the sign bit (S) is the left-most bit, the exponent (E) includes the next eight bits,
and the mantissa or fractional part (F) includes the remaining 23 bits
To subtract two signed numbers, take the 2’s complement of the subtrahend and
add. Discard any final carry bit.
Multiplication
The numbers in a multiplication are the multiplicand, the multiplier, and the product.
These are illustrated in the following decimal multiplication:
Division
Binary coded decimal (BCD) is a way to express each of the decimal digits with a binary code.
There are only ten code groups in the BCD system, so it is very easy to convert between decimal
and BCD. Because we like to read and write in decimal, the BCD code provides an excellent
interface to binary systems.
For example: The decimal number 136 would be represented in BCD as follows:
Conversion of numbers between decimal and BCD is quite simple. To convert from
decimal to BCD, simply write down the four bit binary pattern for each decimal digit. To
convert from BCD to decimal, divide the number into groups of 4 bits and write down the
corresponding decimal digit for each 4 bit group.
There are a couple of variations on the BCD representation, namely packed and
unpacked. An unpacked BCD number has only a single decimal digit stored in each data
byte. In this case, the decimal digit will be in the low four bits and the upper 4 bits of the
byte will be 0. In the packed BCD representation, two decimal digits are placed in each
byte. Generally, the high order bits of the data byte contain the more significant decimal
digit.
The use of BCD to represent numbers isn’t as common as binary in most computer
systems, as it is not as space efficient. In packed BCD, only 10 of the 16 possible bit
patterns in each 4 bit unit are used. In unpacked BCD, only 10 of the 256 possible bit
patterns in each byte are used. A 16 bit quantity can represent the range 0-65535 in
binary, 0-9999 in packed BCD and only 0-99 in unpacked BCD.
It is equally easy to determine a decimal number from a BCD number. Start at the rightmost
bit and break the code into groups of four bits. Then write the decimal digit represented
by each 4-bit group.
BCD Addition
BCD is a numerical code and can be used in arithmetic operations. Addition is the most
important operation because the other three operations (subtraction, multiplication, and
division) can be accomplished by the use of addition. Here is how to add two BCD
numbers:
Step 1. Add the two BCD numbers, using the rules for binary addition
Step 2. If a 4-bit sum is equal to or less than 9, it is a valid BCD number.
Step 3. If a 4-bit sum is greater than 9, or if a carry out of the 4-bit group is generated,
it is an invalid result. Add 6 (0110) to the 4-bit sum in order to skip the six invalidstates and
return the code to 8421. If a carry results when 6 is added, simply add the carry to the next 4-bit
group
DIGITAL CODES
EBCDIC
All IBM mainframe peripherals and operating systems still support EBCDIC, although the
operating systems also provide ASCII and Unicode modes to allow translation between different
encodings (EBCDIC and ASCII-based code pages are incompatible with each other). EBCDIC is
used in modern mainframes only to provide backwards compatibility, and has no specific
advantage over ASCII or Unicode. A number of different versions of EBCDIC are used in
different countries. Some East Asian countries use an extended 16-bit version to allow the
display of Chinese, Japanese and Korean characters.
Hexadecimal Digits
0 ...................... 0 0000
1 ...................... 1 0001
Faculty: Asst. Prof. Rani Augustine IT Department, TIST
IT 201 Digital System Design
2 ...................... 2 0010
3 ...................... 3 0011
4 ...................... 4 0100
5 ...................... 5 0101
6 ...................... 6 0110
7 ...................... 7 0111
8 ...................... 8 1000
9 ...................... 9 1001
10 ..................... A 1010
11 ..................... B 1011
12 ..................... C 1100
13 ..................... D 1101
14 ..................... E 1110
15 ...................... F 1111
BCD Digits
0 ................ 0000
1 ................ 0001
2 ................ 0010
3 ................ 0011
4 ................ 0100
5 ................ 0101
6 ................ 0110
7 ................ 0111
8 ................ 1000
9 ................ 1001