0% found this document useful (0 votes)
47 views24 pages

BCA-digital Logic Two Unit

The document discusses different number systems including decimal, binary, octal and hexadecimal. It provides details on how to convert numbers between these number systems, including the steps to convert the integer and fractional parts. Conversion between decimal, binary, octal and hexadecimal to other bases is explained with examples.

Uploaded by

Kisuke Urahara
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)
47 views24 pages

BCA-digital Logic Two Unit

The document discusses different number systems including decimal, binary, octal and hexadecimal. It provides details on how to convert numbers between these number systems, including the steps to convert the integer and fractional parts. Conversion between decimal, binary, octal and hexadecimal to other bases is explained with examples.

Uploaded by

Kisuke Urahara
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/ 24

Digital Logic BCA first Semester

Digital Logic BCA first Semester

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.

𝑵 = a number and 𝒓 = radix or base of number system

In general, a number expressed in base-r system has coefficients multiplied by powers of r:

𝐴𝑛−1𝑟𝑛−1 + 𝐴𝑛−2𝑟𝑛−2 + ⋯ + 𝐴1𝑟1 + 𝐴0𝑟0 + 𝐴−1𝑟−1 + 𝐴−2𝑟−2 + ⋯ + 𝐴−𝑚𝑟−𝑚

For example, (3456.54)10 can be written as:

3 × 103 + 4 × 102 + 5 × 101 + 6 × 100 + 5 × 10−1 + 4 × 10−2

➢ There are mainly four number system which are used in digital electronics platform.

1. Decimal number system:


- The decimal number system contains ten unique digits from 0 to 9.
- The base or radix is 10.

2. Binary number system:


- The binary number system contains two unique digits 0 and 1.
- The base or radix is 2.

3. Octal number system:


- The octal number system contains eight unique digits from 0 to 7.
- The base or radix is 8.

4. Hexadecimal number system:


- The hexadecimal number system contains sixteen unique digits: 0 to 9 and six letters A,
B, C, D, E and F.
- The base or radix is 16.
Digital Logic BCA first Semester

Number Base Conversion

The possibilities:

Decimal to Other Base System

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

Conversion of Integer part:


- Divide the given integer part of decimal number by base ′𝒓′ successively and write down
all the remainders till the quotient is zero.
- Write all the remainders starting with the MSB (Most Significant Bit) i.e. from bottom to
LSB (Least Significant Bit) i.e. top.

Conversion of Fractional part:


- Multiply the given fractional part of decimal number by base ′𝒓′ successively until the
fractional part becomes zero.
- Note down the integer part starting from first.
Note: If fractional part does not become zero then, result has been taken up to 6 places.

➢ Decimal to Binary Conversion

1. Convert (𝟓𝟏)𝟏𝟎 and (𝟏𝟓𝟐)𝟏𝟎 into binary.


2 152
2 51 2 76 0 (LSB)
2 25 1 (LSB) 2 38 0
2 12 1 2 19 0
2 6 0 2 9 1
2 3 0 2 4 1
2 1 1 2 2 0
0 1 (MSB)
2 1 0
0 1 (MSB)
(51)10 = (110011)2
(152)10 = (10011000)2

2. Convert (𝟒𝟏. 𝟔𝟖𝟕𝟓)𝟏𝟎 into binary.


Conversion of integer part: Conversion of fractional part:
2 41 integer fraction
2 20 1 (LSB) 0.6875×2 1 0.3750
2 10 0 0.3750×2 0 0.7500
2 5 0.7500×2 1 0.5000
0
0.5000×2 1 0.0000
2 2 1
2 1 0
0 1 (MSB)

(41)10 = (101001)2 (0.6875)10 = (0.1011)2

∴ (𝟒𝟏. 𝟔𝟖𝟕𝟓)𝟏𝟎 = (𝟏𝟎𝟏𝟎𝟎𝟏. 𝟏𝟎𝟏𝟏)𝟐


Digital Logic BCA first Semester

➢ Decimal to Octal Conversion

1. Convert (𝟏𝟐𝟓)𝟏𝟎 into octal.


8 125
8 15 5 (LSB)
8 1 7
0 1 (MSB)

(125)10 = (175)8

2. Convert (𝟏𝟓𝟑. 𝟓𝟏𝟑)𝟏𝟎 into octal.


Conversion of integer part: Conversion of fractional part:
8 153 integer fraction
8 19 1 (LSB) 0.513×8 4 0.104
8 2 3 0.104×8 0 0.832
0 2 (MSB) 0.832×8 6 0.656
0.656×8 5 0.248
0.248×8 1 0.984
(153)10 = (231)8
0.948×8 7 0.584

(0.513)10 = (0.406517)8
∴ (𝟏𝟓𝟑. 𝟓𝟏𝟑)𝟏𝟎 = (𝟐𝟑𝟏. 𝟒𝟎𝟔𝟓𝟏𝟕)𝟖

3. Convert (𝟏𝟐𝟓. 𝟔𝟖𝟕𝟓)𝟏𝟎 to octal.


Conversion of integer part: Conversion of fractional part:
integer fraction
8 125
0.6875×8 5 0.5000
8 15 5 (LSB)
0.5000×8 4 0.0000
8 1 7
0 1 (MSB)

(125)10 = (175)8 (0.6875)10 = (54)8

∴ (𝟏𝟐𝟓. 𝟔𝟖𝟕𝟓)𝟏𝟎 = (𝟏𝟕𝟓. 𝟓𝟒)𝟖


Digital Logic BCA first Semester

➢ Decimal to Hexadecimal Conversion

1. Convert (𝟐𝟓𝟗𝟖)𝟏𝟎 to hexadecimal.


16 2598
16 162 6 (LSB)
16 10 2
0 10(A) (MSB)

(2598)10 = (𝐴26)16

2. Convert (𝟗𝟓𝟐. 𝟔𝟐)𝟏𝟎 to hexadecimal.


Conversion of integer part: Conversion of fractional part:
16 952 integer fraction
16 59 8 (LSB) 0.62×16 9 0.92
16 3 11(B) 0.92×16 14(E) 0.72
0 3 (MSB) 0.72×16 11(B) 0.52
0.52×16 8 0.32
0.32×16 5 0.12
(952)10 = (3𝐵8)16
0.12×16 1 0.92

(0.513)10 = (0.9𝐸𝐵851)16

∴ (𝟗𝟓𝟐. 𝟔𝟐)𝟏𝟎 = (𝟑𝑩𝟖. 𝟗𝑬𝑩𝟖𝟓𝟏)𝟏𝟔


Digital Logic BCA first Semester

Any Base to Decimal Conversion


Converting from any base to decimal is done by multiplying each digit by its corresponding
positional weights and summing.
➢ Binary to Decimal

1. Convert (𝟏𝟎𝟏𝟏𝟎)𝟐 into decimal.

(10110)2 = 1 × 24 + 0 × 23 + 1 × 22 + 1 × 21 + 0 × 20
= 16 + 0 + 4 + 2 + 0
= 22
∴ (𝟏𝟎𝟏𝟏𝟎)𝟐 = (𝟐𝟐)𝟏𝟎

2. Convert (𝟏𝟏𝟎𝟏. 𝟎𝟏𝟏)𝟐 into decimal.

(1101.011)2 = 1 × 23 + 1 × 22 + 0 × 21 + 1 × 20 + 0 × 2−1 + 1 × 2−2 + 1 × 2−3


= 8 + 4 + 0 + 1 + 0 + 0.25 + 0.125
= 13.375
∴ (𝟏𝟏𝟎𝟏. 𝟎𝟏𝟏)𝟐 = (𝟏𝟑. 𝟑𝟕𝟓)𝟏𝟎
Digital Logic BCA first Semester

➢ Octal to Decimal

1. Convert (𝟕𝟐𝟒. 𝟐𝟓)𝟖 into decimal.

(724.25)8 = 7 × 82 + 2 × 81 + 4 × 80 + 2 × 8−1 + 5 × 8−2


= 448 + 18 + 4 + 0.25 + 0.0781
= 470.3281
∴ (𝟕𝟐𝟒. 𝟐𝟓)𝟖 = (𝟒𝟕𝟎. 𝟑𝟐𝟖𝟏 )𝟏𝟎

2. Convert (𝟔𝟑𝟎𝟏)𝟖 into decimal.

(6301)8 = 6 × 83 + 3 × 82 + 0 × 81 + 1 × 80
= 3072 + 192 + 0 + 1
= 3265
∴ (𝟔𝟑𝟎𝟏)𝟖 = (𝟑𝟐𝟔𝟓 )𝟏𝟎

➢ Hexadecimal to Decimal

1. Convert (𝑨𝟎𝑭𝟗. 𝟎𝑬𝑩)𝟏𝟔 to decimal.


(𝐴0𝐹9.0𝐸𝐵)16
= 10 × 163 + 0 × 162 + 15 × 161 + 9 × 160 + 0 × 16−1 + 14
× 16−2 + 11 × 16−3

= 40960 + 0 + 240 + 9 + 0 + 0.0546 + 0.0026

= 41209.0572
∴ (𝑨𝟎𝑭𝟗. 𝟎𝑬𝑩)𝟏𝟔 = (𝟒𝟏𝟐𝟎𝟗. 𝟎𝟓𝟕𝟐 )𝟏𝟎

2. Convert (𝑨𝟗𝑭𝟓. 𝑫𝑬)𝟏𝟔 to decimal.

Octal and Hexadecimal number to Binary


➢ Octal to Binary
To convert Octal number to its Binary equivalent, each digit of given octal number is
directly converted to its 3-bit binary equivalent.
Q. Convert (𝟑𝟔𝟕. 𝟓𝟐)𝟖 into Binary.

(367.52)8 = 011 110 111 . 101 010


= 11110111.10101
∴ (𝟑𝟔𝟕. 𝟓𝟐)𝟖 = (𝟏𝟏𝟏𝟏𝟎𝟏𝟏𝟏. 𝟏𝟎𝟏𝟎𝟏)𝟐
Digital Logic BCA first Semester

➢ 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.

(3A9E. B0D)16 = 0011 1010 1001 1110 . 1011 0000 1101


= 11101010011110. 101100001101

∴ (𝟑𝐀𝟗𝐄. 𝐁𝟎𝐃)𝟏𝟔 = (𝟏𝟏𝟏𝟎𝟏𝟎𝟏𝟎𝟎𝟏𝟏𝟏𝟏𝟎. 𝟏𝟎𝟏𝟏𝟎𝟎𝟎𝟎𝟏𝟏𝟎𝟏 )𝟐

Binary to Octal and Hexadecimal Numbers

➢ 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.

1. Convert (𝟏𝟎𝟏𝟏𝟎𝟎𝟎𝟏𝟏𝟎𝟏𝟎𝟏𝟏. 𝟏𝟏𝟏𝟏𝟎𝟎𝟎𝟎𝟎𝟏𝟏𝟎)𝟐 into octal.

(10110001101011.111100000110)2 = 010 110 001 101 011. 111 100 000


110
= 2 6 1 5 3 . 7 4 0 6
= 26153.7406

∴ (𝟏𝟎𝟏𝟏𝟎𝟎𝟎𝟏𝟏𝟎𝟏𝟎𝟏𝟏. 𝟏𝟏𝟏𝟏𝟎𝟎𝟎𝟎𝟎𝟏𝟏𝟎)𝟐 = (𝟐𝟔𝟏𝟓𝟑. 𝟕𝟒𝟎𝟔)𝟖

2. Convert (𝟏𝟏𝟎𝟏𝟎𝟏. 𝟏𝟎𝟏𝟎𝟏𝟎)𝟐 into octal.

(110101.101010)2 = 110 101 . 101 010


= 65.52

∴ (𝟏𝟏𝟎𝟏𝟎𝟏. 𝟏𝟎𝟏𝟎𝟏𝟎)𝟐 = (𝟔𝟓. 𝟓𝟐)𝟖

➢ 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

1. Convert (𝟏𝟎𝟏𝟏𝟎𝟎𝟎𝟏𝟏𝟎𝟏𝟎𝟏𝟏. 𝟏𝟏𝟏𝟏𝟎𝟎𝟎𝟎𝟎𝟏𝟏𝟎)𝟐 into hexadecimal.

(10110001101011.111100000110)2 = 0010 1100 0110 1011. 1111 0000


0110
= 2 C 6 B F 0 6
= 2C6B.F06

∴ (𝟏𝟎𝟏𝟏𝟎𝟎𝟎𝟏𝟏𝟎𝟏𝟎𝟏𝟏. 𝟏𝟏𝟏𝟏𝟎𝟎𝟎𝟎𝟎𝟏𝟏𝟎)𝟐 = (2C6B. F06)𝟏𝟔

Conversion of Octal and Hexadecimal numbers


➢ Octal to Hexadecimal
Steps to convert from octal to its hexadecimal equivalent:
- Each digit of given octal number is converted into its 3-bit binary equivalent.
- Now, form the groups of 4 binary bits to obtain its hexadecimal equivalent.

E.g.

Q. Convert (𝟔𝟕𝟑. 𝟏𝟐𝟒)𝟖 into hexadecimal.

➢ 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

Q. Convert (𝑩𝟗𝑭. 𝑨𝑬)𝟏𝟔 into octal.

(𝐵9𝐹. 𝐴𝐸)16 = (1011 1001 1111 . 1010 1110)2


= (101 110 011 111 . 101 011 100)2
= (5637.534)8

Unsigned and Signed numbers


Unsigned numbers:
- Numbers without any positive and negative sign.
- Represents only magnitude.

Signed magnitude numbers:


- In binary number system, both +ve and –ve values are possible.
- In this, we use 0’s and 1’s to represent every number. The representation of number is
known as signed number.
0 → +ve number
1 → -ve number
E.g.
+7 = 0111
-7 = 1111
This kind of representation for signed number is called signed magnitude representation.
Note: For +ve numbers, the result is the same as the unsigned binary representation.
The signed numbers are represented in three ways: Sign-magnitude form, 1’s complement
form and 2’s complement form
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

Value of a floating-point number = (−1)S × 𝑣𝑎𝑙(𝐹) × 2𝑣𝑎𝑙(𝐸)


BCA first Semester

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.

✓ (𝑟 − 1)’𝑠 complement is known as 9’s complement in base 10 and 1’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.

10’s complement of 52520 = 105-52520 = 47480


10’s complement of 0.3267 = 100-0.3267 = 0.6733
10’s complement of 25.639 = 102-25.639 = 74.361
2’s complement of (101100)2 = (26)10-(101100)2 = (1000000-101100)2 = 010100
2’s complement of (0.0110)2 = (20)10-0.0110 = 0.1010

➢ (𝒓 − 𝟏)’𝒔 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

Subtraction with Complements


➢ Subtraction with r’s Complements
Subtraction of two positive numbers (𝑀 − 𝑁), both of base 𝑟, may be done as
follows: Step-1: Add the minuend 𝑀 to the 𝑟’𝑠 complement of subtrahend 𝑁.
Step-2: Inspect the result obtained in step 1 for an end carry:
(a) If an end carry occurs, discard it.
(b) If an end carry does not occur, take the r’s complement of the number obtained in
step 1 and place a negative sign in front.
E.g.
1. Using 10’s complement, subtract (72532-3250).
Let, 𝑀 = 72532 and
𝑁 = 03250
10’s complement of 𝑁 = (105 − 03250) = 96750
Now,
72532
+96750
1 69282
Here, end carry occurred. So discard it.
So, answer = 69282

2. Using 10’s complement, subtract (3250-72532).


Let, 𝑀 = 03250 and
𝑁 = 72532
10’s complement of 𝑁 = (105 − 72532) = 27468
Now,
03250
+27468
Here, no end carry. . 3071
8
So, answer = −(10’s complement of 30718) = −(105 − 30718) = −69282

3. Using 2’s complement, subtract (1000100-1010100).


Let, 𝑀 = 1000100 and
𝑁 = 1010100
2’s complement of 𝑁 = (27)10 − (1010100)2 = 10000000 − 1010100 = 0101100
Now,
1000100
+0101100
No end carry. . 111000
0
So, answer = −(2’s complement of 1110000) = −[(27)10 − (1110000)2] = −10000
BCA first Semester

4. Subtract (1110.111-1010.101) using 2’s complement.


Let, 𝑀 = 1110.111 and
𝑁 = 1010.101
2’s complement of 𝑁 = (24)10 − (1010.101)2 = 10000 − 1010.101 = 0101.011
Now,
1110.111
+0101.011
1
0100.010
End carry occurred. So discard it.
So, answer = 0100.010

➢ Subtraction with (r-1)’s Complements

The subtraction of 𝑀 − 𝑁, both positive number in base 𝑟, may be calculated in the


following manner:
Step-1: Add the minuend 𝑀 to the (𝑟 − 1)’𝑠 complement of the subtrahend 𝑁.
Step-2: Inspect the result obtained in step 1 for an end carry.
(a) If an end carry occurs, add 1 to the list significant digit (end-round carry)
(b) If an end carry does not occurs, take the (𝑟 − 1)’𝑠 complement of the number
obtained in step 1 and place a negative sign in front.
E.g.
1. Using 9’s complement, subtract (453.35-321.17).
Let, 𝑀 = 453.35 and
𝑁 = 321.17
9’s complement of 𝑁 = 103 − 10−2 − 321.17 = 678.82
Now,
453.35
+678.82
1 132.17
+1
132.1
8
End carry occurred.
End round carry.
∴ Answer = 132.18

2. Using 9’s complement, subtract (3250 – 72532).


Let, 𝑀 = 03250 and
𝑁 = 72532
9’s complement of 𝑁 = 105 − 100 − 72532 = 27467
Now,
BCA first Semester
Here, no end carry. . 03250
+27467
3071
7
So, answer = −(9’s complement of 30717) = −(105 − 100 − 30718) = −69282
BCA first Semester

3. Using 1’s complement, subtract (1000100-1010100).


Let, 𝑀 = 1000100 and
𝑁 = 1010100
1’s complement of 𝑁 = 0101011
Now,
1000100
+0101011
No end carry. . 110111
1
So, answer = −(1’s complement of 1101111) = −10000

4. Subtract (1010100 - 1000100) using 1’s complement.


Let, 𝑀 = 1010100 and 𝑁 = 1000100
1’s complement of 𝑁 = 0111011
1010100
+0111011
1 0001111
+1
001000 ∴ Answer = 10000
0
End carry occurred.
End round carry.

Binary Codes

When numbers, letters or words are represented by a special group of binary


symbols/combinations, we say that they are being encoded and the group of symbols is called
a code. Some familiar binary codes are: Decimal Codes, Error-detection Codes, The
Reflected Code, Alphanumeric Codes etc.

Decimal Codes

The representation of decimal digits by binary combinations is known as decimal codes.


Binary codes from decimal digits require minimum of four bits. Numerous different codes
can be obtained by arranging four or more bits in ten distinct possible combinations. Some
decimal codes are-
- BCD
- Excess-3

➢ Binary-Coded-Decimal (BCD) Code


If each digit of a decimal number is represented by its binary equivalent, the result is a
BCA first Semester
code called binary coded decimal (BCD). It is possible to assign weights to the binary bits
according to their positions. The weights in the BCD code are 8,4,2,1.
BCA first Semester

➢ 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/Gray Code

- 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.

Q. Convert (123)10 to gray code.


Binary code of (123)10 = (1111011)2
∴ (123)10 = (1000110)GrayCode

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.

➢ Extended ASCII characters

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.
-

You might also like