BCA-digital Logic Two Unit
BCA-digital Logic Two Unit
Unit-2
Number Systems
Number System
In general, in any number system there is an ordered set of symbols known as digits with
rules defined for performing arithmetic operations like addition, multiplication etc. A
collection of these digits makes a number in general has two parts- integer and fractional. Set
apart by a radix point (.), i.e.
➢ There are mainly four number system which are used in digital electronics platform.
The possibilities:
The decimal number can be an integer or floating-point integer. When the decimal number is
a floating-point integer, then we convert both part (integer and fractional) of the decimal
number in the isolated form (individually). There are the following steps that are used to
convert the decimal number into a similar number of any base ′𝒓′.
Digital Logic BCA first Semester
(125)10 = (175)8
(0.513)10 = (0.406517)8
∴ (𝟏𝟓𝟑. 𝟓𝟏𝟑)𝟏𝟎 = (𝟐𝟑𝟏. 𝟒𝟎𝟔𝟓𝟏𝟕)𝟖
(2598)10 = (𝐴26)16
(0.513)10 = (0.9𝐸𝐵851)16
(10110)2 = 1 × 24 + 0 × 23 + 1 × 22 + 1 × 21 + 0 × 20
= 16 + 0 + 4 + 2 + 0
= 22
∴ (𝟏𝟎𝟏𝟏𝟎)𝟐 = (𝟐𝟐)𝟏𝟎
➢ Octal to Decimal
(6301)8 = 6 × 83 + 3 × 82 + 0 × 81 + 1 × 80
= 3072 + 192 + 0 + 1
= 3265
∴ (𝟔𝟑𝟎𝟏)𝟖 = (𝟑𝟐𝟔𝟓 )𝟏𝟎
➢ Hexadecimal to Decimal
= 41209.0572
∴ (𝑨𝟎𝑭𝟗. 𝟎𝑬𝑩)𝟏𝟔 = (𝟒𝟏𝟐𝟎𝟗. 𝟎𝟓𝟕𝟐 )𝟏𝟎
➢ Hexadecimal to Binary
To convert Hexadecimal number to its Binary equivalent, each digit of given hexadecimal
number is converted to its 4-bit binary equivalent.
Q. Convert (𝟑𝑨𝟗𝑬. 𝑩𝟎𝑫)𝟏𝟔 into Binary.
➢ Binary to Octal
As 8 = 23, for binary to octal conversion groups of 3 binary bits each are formed in the
binary number. After forming groups, each group of three binary bits is converted to its
octal equivalent.
- For integer part of the binary number, the group of three bits is formed from right to
left. In the binary fraction the group of three bits is formed from left to right. If there are
not 3 bits available at last, just stuff ‘0’ to make 3 bits group.
➢ Binary to Hexadecimal
As 16 = 24, for binary to hexadecimal conversion groups of 4 binary bits each are
formed in the binary number. After forming groups, each group of four binary bits is
converted to its hexadecimal equivalent.
Digital Logic BCA first Semester
- For integer part of the binary number, the group of four bits is formed from right to left.
In the binary fraction the group of four bits is formed from left to right. If there are not 4
bits available at last, just stuff ‘0’ to make 4 bits group.
Digital Logic BCA first Semester
E.g.
➢ Hexadecimal to Octal
Steps to convert from hexadecimal to its octal equivalent:
- Each digit of given hexadecimal number is converted into its 4-bit binary equivalent.
- Now, form the groups of 3 binary bits to obtain its octal equivalent.
E.g.
BCA first Semester
1. Sign-Magnitude form
In this form, a binary number has a bit for a sign symbol. If this bit is set to 1, the number
will be negative else the number will be positive if it is set to 0. Apart from this sign-bit,
the n-1 bits represent the magnitude of the number.
Syntax:
Sign Bit Actual binary
E.g. +7 = 0111
-7 = 1111
2. 1's Complement
By inverting each bit of a number, we can obtain the 1's complement of a number. The
negative numbers can be represented in the form of 1's complement. In this form, the
binary number also has an extra bit for sign representation as a sign-magnitude form.
Syntax:
Sign Bit 1’s complement of actual binary
E.g. 7 = 111
1’s complement = 000
- 7 = 1000
3. 2's Complement
By inverting each bit of a number and adding plus 1 to its least significant bit, we can
obtain the 2's complement of a number. The negative numbers can also be represented in
the form of 2's complement. In this form, the binary number also has an extra bit for sign
representation as a sign-magnitude form.
Syntax:
Sign Bit 2’s complement of actual binary
E.g. 7 = 111
1’s complement = 000
2’s complement = 000 + 1 = 001
- 7 = 1001
Floating-Point Representation
A floating-point number is represented by the triple:
- S is the sign bit (0 is +ve and 1 is –ve)
▪ Representation is called sign and magnitude.
- E is the Exponent field (signed)
▪ Very large numbers have large positive exponents
▪ Very small close-to-zero numbers have negative exponents
▪ More bits in exponent field increases range of values
- F is the fraction field (fraction after binary point)
▪ More nits in fraction field improves the precision of FP numbers.
S Exponent Fraction
Binary Addition
Addition rules: Example:
0+0=0
0+1=1
1+0=1
1 + 1 = 0 with carry 1
1 + 1 + 1 = 1 with carry 1
Binary Subtraction
Subtraction rules: Example:
0-0=0
1-0=1
0 - 1 = 1 with borrow 1
1-1=0
Binary Multiplication
Multiplication rules: Example:
0x0=0
0x1=0
1x0=0
1x1=1
Binary Division
BCA first Semester
Complements
Complements are used in digital computers for simplifying the subtraction operation and for
logical manipulations.
There are two types of complements for each base−𝑟 system:
a) The 𝑟’𝑠 complement and
b) The (𝑟 − 1)’𝑠 complement.
✓ 𝑟’𝑠 complement is known as 10’s complement in base 10 and 2’s complement in base 2.
➢ 𝒓’𝒔 complement
Given a positive number 𝑁 in base 𝑟 with an integer part of 𝑛 digits, the 𝑟’𝑠 complement
of 𝑁 is defined as
𝑟𝑛 − 𝑁, 𝑖𝑓 𝑁 ≠ 0 0,
The 𝑟’𝑠 complement of 𝑁 = {
𝑖𝑓 𝑁 = 0
E.g.
➢ (𝒓 − 𝟏)’𝒔 complement
Given a positive number 𝑁 in base 𝑟 with an integer part of 𝑛 digits and a fractional part
of 𝑚 digits, the (𝑟 − 1)’𝑠 complement of 𝑁 is defined as:
The (𝑟 − 1)’𝑠 complement of 𝑁 = 𝑟𝑛 − 𝑟−𝑚 − 𝑁
E.g.
9’s complement of (52520)10 = (105-100-52520) = 47479
9’s complement of (0.3267)10 is (100-10-4-0.3267) = 0.6732
9’s complement of (25.693)10 is (102-10-3-25.693) = 74.306
1’s complement of (101100)2 is (26-20)10-(101100)2 = 111111-101100 = 010011
1’s complement of (0.0110)2 is (1-2-4)10-(0.0110)2 = 0.1001
BCA first Semester
Binary Codes
Decimal Codes
➢ Excess-3 Code
This is an unweighted code. Its code assignment is obtained from the corresponding value
of BCD after the addition of 3.
Q. Convert decimal number 23 to Excess-3 code.
So, according to excess-3 code we need to add 3 to both digit in the decimal number then
convert into 4-bit binary number for result of each digit. Therefore,
2 3
+3 3
5 6
5 6 = 0101 0110 which is required excess-3 code for given decimal number 23
Q. Convert decimal number 15.46 into Excess-3 code.
According to excess-3 code we need to add 3 to both digit in the decimal number then
convert into 4-bit binary number for result of each digit. Therefore,
1 5.4 6
+ 3 3 .3 3
4 8.79
48.79 = 0100 1000.0111 1001 which is required excess-3 code for given decimal
number 15.46.
Error-detection Codes
- An error detection codes can be used to detect errors during transmission. A parity bit is
an extra bit included with a message to make the total number of 1’s either odd or even.
- For a message of four bits parity (P) is chosen so that the sum of all 1’s is odd (in all five
bits) or the sum of all 1’s is even. In the receiving end, all the incoming bits (in this case
five) are applied to a “parity-check” network for checking.
- An error is detected if the check parity does not correspond to the adopted one. The parity
method detects the presence of one, three or any odd combination of errors. An even
combination of errors is undetectable. Additional error-detection schemes may be needed
to take care of an even combination of errors.
BCA first Semester
- The Reflected code, also called Gray code is unweighted and is not an arithmetic code;
that is, there are no specific weights assigned to the bit positions.
- It is a binary numeral system where two successive values differ in only one bit (binary
digit).
- For instance, in going from decimal 3 to decimal 4, the Gray code changes from 0010 to
0110, while the binary code changes from 0011 to 0100, a change of three bits. The only
bit change is in the third bit from the right in the Gray code; the others remain the same.
Alphanumeric Code
- In order to communicate, we need not only numbers, but also letters and other symbols.
In the strictest sense, alphanumeric codes are codes that represent numbers and alphabetic
characters (letters). Most such codes, however, also represent other characters such as
symbols and various instructions necessary for conveying information.
- The ASCII is the most common alphanumeric code.
➢ ASCII Code
ASCII is the abbreviation for American Standard Code for Information Interchange.
ASCII is a universally accepted alphanumeric code used in most computers and other
electronic equipment. Most computer keyboards are standardized with the ASCII. When we
enter a letter, a number, or control command, the corresponding ASCII code goes into the
computer.
- ASCII has 128 characters and symbols represented by a 7-bit binary code. Actually,
ASCII can be considered an 8-bit code with the MSB always 0. This 8-bit code is 00
through 7F in hexadecimal.
- The first thirty-two ASCII characters are non-graphic commands that are never printed or
displayed and are used only for control purposes. Examples of the control characters are
""null," "line feed," "start of text," and "escape."
- The other characters are graphic symbols that can be printed or displayed and include the
letters of the alphabet (lowercase and uppercase), the ten decimal digits, punctuation signs
and other commonly used symbols.
In addition to the 128 standard ASCII characters, there are an additional 128 characters that
were adopted by IBM for use in their PCs (personal computers). Because of the popularity of
the PC, these particular extended ASCII characters are also used in applications other than
PCs and have become essentially an unofficial standard. The extended ASCII characters are
represented by an 8-bit code series from hexadecimal 80 to hexadecimal FF.
-