0% found this document useful (0 votes)
79 views63 pages

BCA DL Unit 2

The document is a course outline for a BCA subject on Digital Logic, focusing on number systems including binary, octal, and hexadecimal, along with their conversions and arithmetic operations. It covers representations of signed numbers, fixed-point and floating-point representations, and various methods for converting between number systems. Additionally, it discusses binary arithmetic operations such as addition, subtraction, multiplication, and division, as well as complements used in digital arithmetic.

Uploaded by

dwe085788
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views63 pages

BCA DL Unit 2

The document is a course outline for a BCA subject on Digital Logic, focusing on number systems including binary, octal, and hexadecimal, along with their conversions and arithmetic operations. It covers representations of signed numbers, fixed-point and floating-point representations, and various methods for converting between number systems. Additionally, it discusses binary arithmetic operations such as addition, subtraction, multiplication, and division, as well as complements used in digital arithmetic.

Uploaded by

dwe085788
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 63

A Course for

BCA
Year/Part: I/I

Subject: Digital Logic ( BCA)


Unit 2: Number System

Presented
BY
Er. Ganesh Kumal
Contents
2.1 Binary, Octal, & Hexadecimal Number
System and Their Conversions
2.1.1 Representation of Signed Numbers- Floating
Point Number
2.1.2 Binary Arithmetic
2.2 Representation of BCD, ASCII, Excess 3, Gray
Code, Error Detecting and Correcting Codes.

Prepared By: Er. Ganesh Kumal 2


2.1 Number System and Their
Conversion
• If base or radix of a number system is ‘r’, then the digits
present in that number system are ranging from zero to
r-1.
• The total digits present in that number system is ‘r’. So,
we will get various number systems, by choosing the
values of radix as greater than or equal to two.
• The following number systems are the most commonly
used.
1. Decimal Number system
2. Binary Number system
3. Octal Number system
4. Hexadecimal Number system
Prepared By: Er. Ganesh Kumal 3
Decimal Number
• The decimal number system has 10 digits
• These are : 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.
• Decimal number system has the base = 10
102 101 100.10 -110 -2 10 -3……
Decimal point
Example 1: 47= 4 x 101 + 7 x 100
= 40 + 7 = 47

Example 2: 568.23= 5 x 102 + 6 x 101 + 8 x 100.2 x 10-1 + 3 x 10-2


= 500 + 60 +8 + 0.2 + 0.3
= 568.23
Prepared By: Er. Ganesh Kumal 4
Binary Number
• The binary number system has two digits
(bits). ‘0’ or ‘1’ = bit
Group of 4-bits = Nibble
• These are: 0, 1. Group of 8-bits = Byte

• The binary number system has the base = 2


22 21 20.2 -1 2 -2 2 -3……
binary point
The weights of a bit
(1101.011)2 = (1 × 23) + (1 × 22) + (0 × 21) + (1 × 20)
increases from right to + (0 × 2-1) + (1 × 2-2) + (1 × 2-3)
left in a binary number
system
Prepared By: Er. Ganesh Kumal 5
Octal Number System
• The octal number system has 8 digits.
• These are: 0, 1, 2, 3, 4, 5, 6, 7.
• The base of octal system has 8.
82 81 80.8 -1 8 -2 8 -3……
Octal point
Mathematically, we can write it as
1457.236 = (1 × 83) + (4 × 82) + (5 × 81) + (7 × 80) + (2 × 8-1) +
(3 × 8-2) + (6 × 8-3)

Prepared By: Er. Ganesh Kumal 6


Hexadecimal Number System
• The hexadecimal system has 16 digits.
• These are: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E and F.
• The base of hexadecimal system has 16.

162 161 160. 16 -1 16 -2 16 -3……


hexadecimal point
Mathematically, we can write it as
1A05.2C4 = (1 × 163) + (10 × 162) + (0 × 161) + (5 × 160) +
(2 × 16-1) + (12 × 16-2) + (4 × 16-3)

Prepared By: Er. Ganesh Kumal 7


Decimal Binary Octal Hexadecimal
0 0000 0 0
1 0001 1 1
Decimal Binary
2 0010 2 2
0 0 0 0
3 0011 3 3
1 0 0 1
4 0100 4 4
2 0 1 0
5 0101 5 5
3 0 1 1
6 0110 6 6
4 1 0 0
7 0111 7 7
5 1 0 1
8 1000 10 8
6 1 1 0
9 1001 11 9
7 1 1 1
10 1010 12 A
11 1011 13 B
12 1100 14 C Table: 3-bit binary system

13 1101 15 D
14 1110 16 E
15 1111 17 F
Table: NumberPrepared
System By: Er. Ganesh Kumal 8
Number Conversion System
(I) Decimal to Other Base System
i. Divide the decimal number to be converted by the value
of the new base.
ii. Get the remainder from step 1 as the rightmost digit
(least significant digit) of new base number.
iii. Divide the quotient by the base.
iv. Record the remainder from step 3 as the next digit (to
the left) of the new base.
 Repeat step (iii) and (iv) getting remainders from right
to left until the quotient becomes zero in step (iii).
The last remainder obtained will be the MSD of the
new base.

Prepared By: Er. Ganesh Kumal 9


Decimal to Binary Conversion
Example
Decimal to Binary Conversion: (25.692)10  (?)2

(25.692)10 = (11001.1011)2

Prepared By: Er. Ganesh Kumal 10


Decimal to Octal Conversion:
(239.513)10  (?)8

0.513 X 8 = 4.104 4
7 0.104 X 8 = 0.832 0
0. 832 X 8 = 6.656 6
0. 656 X 8 = 5.248 5
0.248 X 8 = 1.984 1
Read down

(239.513)10 = (357.40651)8

Prepared By: Er. Ganesh Kumal 11


Decimal to Hexadecimal Conversion
(3479.342)10 = ( ? )16
0.342 x 16 = 5.472 5
0.472 x 16 = 7.552 7
0.552 x 16 = 8.832 8
0.832 x 16 = 13.312 D
Read down

(3479.342)10 = (D97.578D)16

Prepared By: Er. Ganesh Kumal 12


(II) Other Base System to Decimal
System
i. Determine the column (positional) value of
each digit. This depends on the position of
the digit and the base of the number system.
ii. Multiply the obtained column value (in step i)
by the digits in the corresponding column.
iii. Sum the products calculated in step (ii). The
total is the equivalent value in decimal.

Prepared By: Er. Ganesh Kumal 13


Example
Binary to Decimal: (11011001.1011)2  (?)10

Prepared By: Er. Ganesh Kumal 14


Prepared By: Er. Ganesh Kumal 15
Hexadecimal to Decimal

Convert base 5 to decimal system


(234)5 = (…?…)10
Prepared By: Er. Ganesh Kumal 16
(III) Other Base System to Non-decimal
System
i. Convert the original number to a decimal
number (base 10).
ii. Convert the decimal number so obtained to
the new base number.
Example:
• Binary to Octal and vice-versa.
• Binary to Hexadecimal and vice-versa.

Prepared By: Er. Ganesh Kumal 17


Prepared By: Er. Ganesh Kumal 18
Octal to Hex Conversion

Prepared By: Er. Ganesh Kumal 19


2.1.1 Representation of Signed
Number
• Representation of number
– Unsigned number: 0, 1, 2, 3,… (only +ve number)
– Signed number: 3, 2,1, 0, -1, -2, -3 (both +ve and negative)
• Signed number
– In computing, signed number representations are
required to encode negative numbers in
binary number systems.
– In mathematics, negative numbers in any base are
represented by prefixing them with a minus sign ("−").
– Due to hardware limitations, computer must represent
information with 1’s and 0’s; including sign of a number.
• 1 - negative
• 0 - positive

Prepared By: Er. Ganesh Kumal 20


Fixed-Point Representation
• Fixed-point numbers are those in which the
position of the decimal point remains fixed
independent of the value that number is
representing.
• There are two ways of specifying the radix
point in register:
I. Floating point representation
II. Fixed point representation
• Fixed point notation has an implied binary point
between the integer and fraction bits.
• Example:

Prepared By: Er. Ganesh Kumal 21


Prepared By: Er. Ganesh Kumal 22
Floating Point Representation
• Floating point arithmetic can provide higher
levels of precision for a particular bit-width
than fixed-point arithmetic.
• Important terms:
Sign: 1 for negative and 0 for positive
number
Mantissa: fixed point number, may be
fraction or an integer.
Exponent: position of the decimal( or
binary) point.

Prepared By: Er. Ganesh Kumal 23


Example:
(263.3)10
263 = 100000111
0.3 = .01001100110011…..

263.3 = 100000111.0100110011……….
= 1.000001110100110011….x 28

Prepared By: Er. Ganesh Kumal 24


2.1.2 Binary Arithmetic
• Binary arithmetic is essential part of all the digital computers and many
other digital systems.
Binary Addition
• It is a key for binary subtraction, multiplication and division. There are
four rules of binary addition:
Table 2.2 : Truth Table of Binary Addition
Example:

• In fourth case, a binary addition is creating a sum of (1 + 1= 10), i.e. 0 is


written in the given column and a carry of 1 over to the next column.

Prepared By: Er. Ganesh Kumal 25


Binary Subtraction
• Difference and borrow, these two Example:
terms will be used very
frequently in the binary
subtraction. There are four rules
of binary subtraction:
Table 6.5: truth Table of Binary
Subtraction

Prepared By: Er. Ganesh Kumal 26


Binary Multiplication
• Binary multiplication is similar to
decimal multiplication. It is simpler
than decimal multiplication because
only 0s and 1s are involved. There are
four rules for binary multiplication.
Table 6.6: Truth Table of Binary
Multiplication

Binary Division: Binary division is similar to


decimal division.

Prepared By: Er. Ganesh Kumal 27


Octal Addition
• Following octal addition table will help you to
handle octal addition: Example:
Octal Addition

Prepared By: Er. Ganesh Kumal 28


Hexa-decimal Addition/Subtraction
Addition Subtraction

Prepared By: Er. Ganesh Kumal 29


Hexa-decimal Addition/Subtraction
Addition Subtraction

Prepared By: Er. Ganesh Kumal 30


Complements
• Complements are used in the digital
computers in order to simplify the subtraction
operation and for the logical manipulation.
• There are two types of complements:
– Radix complement (r’s complement)
– Diminished complement ( r-1)’s complement

Prepared By: Er. Ganesh Kumal 31


9’s Complement
To obtain the 9’s complement of any number we have to subtract the
number with (10n – 1) where n = number of digits in the number, or in a
simpler manner we have to subtract each digit of the given decimal
number with 9.
Decimal 9’s Complement 9’s complement of 456 is
0 9 • 10 3-1=999 since no of digit

is 3
1 8 • Now we have to subtract
2 7 456 from 999 as
999
3 6
(-)456
4 5 -------
5 4 543
So 9’s complement of 456 is
6 3 543
7 2
8 1
9 0
10’s Complement
• The 10's complement is a mathematical operation
used in digital arithmetic to represent negative
numbers in a way that simplifies subtraction
operations. It is particularly common in decimal
systems.
• To get its 10's complement:
– For each digit in the number, subtract it from 9.
– Add 1 to the least significant digit (rightmost digit) after
performing the subtraction.
• For example: 10’s complement of 352 is
– 9’s complement of 352 is 647
– 10’s complement of 352 is 647 + 1= 648
Binary Complement
1’s Complement 2’s Complement
• The 2’s complement of binary number
• 1’s complement of a
is obtained by adding 1 to the least
number is found by significant bit (LSB) of the 1’s
changing all 1’s to 0’s and complement.
0’s to 1’s. • 2’s complement = 1’s complement + 1

Prepared By: Er. Ganesh Kumal 34


1’s complement subtraction

• Subtracting smaller
number from larger one,
the method is as follows:
– Determine 1’s complement
of the smaller one.
– Add 1’s complement of the
smaller one to the larger
one.
– Remove the carry and add When subtracting larger number from
it to the result. The carry is smaller one, there is no carry and the
called end around carry. result is in 1’s complement form and
opposite sign (negative).

Prepared By: Er. Ganesh Kumal 35


2’s Complement Subtraction
• For subtracting a smaller • Example:
number from larger one, • Subtract (1001)2 from (1100)2,
the method is as follows: by 2’s complement method.
– Find the 2’s complement of 1100
the smaller number.
– Add 2’s complement to the 2’s comp. of 1001 + 0111
larger one. End around carry 10011
– Discard carry. Result= 11
When subtracting larger discard carry
number from smaller one,
there is no carry and the Class work: Subtract by 2’s complement
result is in 2’s complement method.
form and opposite sign i. (111)2 from (1000)2
(negative).
ii. (1110)2 from (1000)2

Prepared By: Er. Ganesh Kumal 36


1.3 Binary Codes
• Classification of Binary codes
– Weighted code
– Non-weighted code
Weighted Code
 Weighted binary codes obey the positional weight
principle.
 Each position of the number represents specific
weight. Several systems of the codes are used to
express the decimal digit 0 through 9. In these codes,
each decimal digit is represented by a group of 4 bits.
 Example: BCD Code,

Prepared By: Er. Ganesh Kumal 37


Binary Coded Decimal (BCD) or 8421
Code
• Each decimal digit is represented by a 4-bit binary
number.
• In the BCD, with 4-bits we can represent 16 numbers
(0000 to 1111).
• But in BCD code only first 10 numbers of these are
used (0000 to 1001).
• The remaining six code combinations (1010 to 1111)
are invalid in BCD.

Prepared By: Er. Ganesh Kumal 38


Decimal number Binary number Binary Coded Decimal(BCD)

0 0000 0000
1 0001 0001
2 0010 0010
3 0011 0011
4 0100 0100 Valid in Binary
5 0101 0101
6 0110 0110
7 0111 0111
8 1000 1000
9 1001 1001
10 1010 0001 0000
11 1011 0001 0001
12 1100 Invalid in BCD 0001 0010 Invalid in Binary
13 1101 0001 0011
14 1110 0001 0100
Prepared By: Er. Ganesh Kumal 39
15 1111 0001 0101
BCD Addition

Prepared By: Er. Ganesh Kumal 40


Non-weighted Code
Non-weighted Code
• In this type of binary codes, the positional
weights are not assigned.
• The examples of non-weighted codes are: Excess-
3 code and Gray code.
Excess-3 code
• Non -weighted code to express decimal number.
• The Excess-3 code words are derived from the
8421 (BCD) code words adding (011)2 to each
code word in 8421.
Prepared By: Er. Ganesh Kumal 41
Excess-3 Code
The Excess-3 code is obtained as follows:
Decimal number  8421 code + (011)2  Ex-3 code

Prepared By: Er. Ganesh Kumal 42


Decimal to Ex-3 and vice-versa
• Decimal to Ex-3 • Excess-3 to Decimal
i. Convert each decimal i. Subtract 3 from each
digit to equivalent BCD 4-bit of Ex-3 to get BCD
ii. Add 3 (0011) to each ii. Convert each BCD to
BCD code. equivalent decimal.

Prepared By: Er. Ganesh Kumal 43


Gray Code (Reflected Code)
• It is non-weighted code, so no specific weight assigned to the bit position.
• It has very special feature that, only one bit will change each time the
decimal number is incremented.

Table 2.3:Binary and Gray Code


Gray to Binary and Binary to Gray
Conversion
Gray to Binary Conversion Binary to Gray Conversion

Prepared By: Er. Ganesh Kumal 45


Error Detection Code
• An error detection code is a binary code that
detects digital errors during transmission.
• The detected error can not be corrected but
their presence is indicated. Example: Parity bit

1
Error Detection and Correction
Error detection:
– Parity (Odd, Even)
– Check sum
– Cyclic Redundancy Check (CRC)

Error Correction: Hamming Codes

Prepared By: Er. Ganesh Kumal 47


Parity Bit
Parity Bit
• An extra bit included to make the total number of 1’s in
the resulting code word either even or odd.
• It detects only odd number (1, 3, 5, …..) of errors.
Even Parity
• Even parity means the number of 1’s in the given word
including the parity bit should be even ( 0, 2, 4, …).
Odd Parity
• Odd parity means the number of 1’s in the given word
including the parity bit should be odd ( 1, 3, 5, …).

Prepared By: Er. Ganesh Kumal 48


Parity Bit Generation

Prepared By: Er. Ganesh Kumal 49


Algorithm (Even Parity)

Prepared By: Er. Ganesh Kumal 50


Checksum
• In checksum error detection scheme, the data is divided into k
segments each of m bits.
• In the sender’s end the segments are added using 1’s
complement arithmetic to get the sum. The sum is
complemented to get the checksum.
• The checksum segment is sent along with the data segments.
• At the receiver’s end, all received segments are added using 1’s
complement arithmetic to get the sum. The sum is
complemented.
• If the result is zero, the received data is accepted; otherwise
discarded.

Prepared By: Er. Ganesh Kumal 51


Example:

Prepared By: Er. Ganesh Kumal 52


Cyclic Redundancy Check (CRC)
• Unlike checksum scheme, which is based on addition, CRC
is based on binary division.
• In CRC, a sequence of redundant bits, called cyclic
redundancy check bits, are appended to the end of data
unit so that the resulting data unit becomes exactly
divisible by a second, predetermined binary number.
• At the destination, the incoming data unit is divided by the
same number. If at this step there is no remainder, the data
unit is assumed to be correct and is therefore accepted.
• A remainder indicates that the data unit has been damaged
in transit and therefore must be rejected.

Prepared By: Er. Ganesh Kumal 53


CRC Algorithm

Prepared By: Er. Ganesh Kumal 54


Example:

Prepared By: Er. Ganesh Kumal 55


Error Correcting Codes
• Error correcting codes are used to correct the
errors present in the received data bit-stream
so that we will get the original data.
• Error correcting codes also use the similar
strategy of error detection codes.
• Therefore, to detect and correct the errors,
additional bits are appended to the data bits
at the time of transmission.
• Example : Hamming Code

Prepared By: Er. Ganesh Kumal 56


Alphanumeric Codes
• Alphanumeric code is the set of elements that
includes the 10 decimal digits, 26 letters of
the alphabet and special characters such as $,
%, + etc.
American Standard Code for Information
Interchange (ASCII)
• The standard binary code for the
alphanumeric characters is called ASCII.
• It uses 7-bits to code 128 characters.
Prepared By: Er. Ganesh Kumal 57
ASCII Code

Prepared By: Er. Ganesh Kumal 58


ASCII Code

Prepared By: Er. Ganesh Kumal 59


Extended BCD Interchange
Code(EBCDIC)
• Used for data communication in IBM equipment
• 8-bits used for each character
• EBCDIC has the same character symbols as ASCII, but the bit assignment
for character is different.

Prepared By: Er. Ganesh Kumal 60


Signed and Unsigned Number
• Signed Number:
• Positive integers including zero can be represented as unsigned
number.
• Unsigned Number:
• To represent negative integers, we need a notation for negative
values.
• If the binary number is signed, then the leftmost bit represent the
sign and rest of the bits represent the number.
• The convention is to make the sign bit 0 for positive number and 1
for negative number.
• For example:
+ 9 = 01001
 9 = 11001

Prepared By: Er. Ganesh Kumal 61


Signed Number Representation
• Consider number 9 is represented in binary with
8-bits: 00001001
• + 9 is represented with sign bit 0 in the leftmost
position followed by binary equivalent of 9.
• Although there is only one way to represent + 9,
there are three different ways to represent  9.
• In signed -magnitude representation: 10001001
• In signed-1’s complement representation: 11110110
• In signed- 2’s complement representation: 11110111
Prepared By: Er. Ganesh Kumal 62
Unit 2 End !!

Any Queries ??

You might also like