Nothing Special   »   [go: up one dir, main page]

Module 6 GEC 3

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Bachelor of Science in Civil Engineering 1

GEC 3-Mathematics in the Modern World


MODULE 6: Codes

INTRODUCTION

Code powers everything from laptops to vending machines to cars. But how does it work?
In this chapter, you'll learn what code is, why so many coding languages exist, and how
they are matched to achieve specific tasks. Most importantly, you’ll learn why having a
basic understanding of code could be beneficial for you.

OBJECTIVES

 Identify and categorize codes;


 Figure out the use of codes in the society.
 Determine the use of computer integers, with respect to mathematical theory.
 Determine Hamming code as a set of error-correction codes that can be used to detect
and correct the errors.

DISCUSSION PROPER

Binary Code

In the coding, when numbers, letters or words are represented by a specific group of
symbols, it is said that the number, letter or word is being encoded. The group of
symbols is called as a code. The digital data is represented, stored and transmitted as
group of binary bits. This group is also called as binary code. The binary code is
represented by the number as well as alphanumeric letter.

Advantages of Binary Code

Following is the list of advantages that binary code offers.


• Binary codes are suitable for the computer applications.
• Binary codes are suitable for the digital communications.
• Binary codes make the analysis and designing of digital circuits if we use the
binary codes.
• Since only 0 & 1 are being used, implementation becomes easy.

Classification of binary codes

The codes are broadly categorized into following four categories.


• Weighted Codes
• Non-Weighted Codes
• Binary Coded Decimal Code
• Alphanumeric Codes
• Error Detecting Codes
• Error Correcting Codes

Weighted Codes

Weighted binary codes are those binary codes which obey the positional weight
principle. Each position of the number represents a specific weight. Several systems of

Prepared by: Engr. Jerico P. Fiel


Bachelor of Science in Civil Engineering 2

the codes are used to express the decimal digits 0 through 9. In these codes each
decimal digit is represented by a group of four bits.

Non-Weighted Codes

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

The Excess-3 code is also called as XS-3 code. It is non-weighted code used to express
decimal numbers. The Excess-3 code words are derived from the 8421 BCD code words
adding (0011)2 or (3)10 to each code word in 8421. The excess-3 codes are obtained as
follows

Gray Code

It is the non-weighted code and it is not arithmetic codes. That means there are no specific
weights assigned to the bit position. It has a very special feature that, only one bit will
change each time the decimal number is incremented as shown in fig. As only one bit
changes at a time, the gray code is called as a unit distance code. The gray code is a cyclic
code. Gray code cannot be used for arithmetic operation.

Application of Gray code

• Gray code is popularly used in the shaft position encoders.


• A shaft position encoder produces a code word which represents the angular
position of the shaft.

Prepared by: Engr. Jerico P. Fiel


Bachelor of Science in Civil Engineering 3

Binary Coded Decimal (BCD) code

In this code each decimal digit is represented by a 4-bit binary number. BCD is a way to
express each of the decimal digits with a binary code. In the BCD, with four bits we can
represent sixteen numbers (0000 to 1111). But in BCD code only first ten of these are used
(0000 to 1001). The remaining six code combinations i.e. 1010 to 1111 are invalid in BCD.

Advantages of BCD Codes

• It is very similar to decimal system.


• We need to remember binary equivalent of decimal numbers 0 to 9 only.

Disadvantages of BCD Codes

• The addition and subtraction of BCD have different rules.


• The BCD arithmetic is little more complicated.
• BCD needs more number of bits than binary to represent the decimal number. So
BCD is less efficient than binary.

Alphanumeric codes

A binary digit or bit can represent only two symbols as it has only two states '0' or '1'.
But this is not enough for communication between two computers because there we
need many more symbols for communication. These symbols are required to represent
26 alphabets with capital and small letters, numbers from 0 to 9, punctuation marks
and other symbols.

The alphanumeric codes are the codes that represent numbers and alphabetic
characters. Mostly such codes also represent other characters such as symbol and
various instructions necessary for conveying information. An alphanumeric code should
at least represent 10 digits and 26 letters of alphabet i.e. total 36 items. The following
three alphanumeric codes are very commonly used for the data representation.
• American Standard Code for Information Interchange (ASCII).
• Extended Binary Coded Decimal Interchange Code (EBCDIC).
• Five bit Baudot Code.
ASCII code is a 7-bit code whereas EBCDIC is an 8-bit code. ASCII code is more
commonly used worldwide while EBCDIC is used primarily in large IBM computers.

Codes Conversion

There are many methods or techniques which can be used to convert code from one
format to another. We'll demonstrate here the following
• Binary to Decimal, vice versa
• BCD to Decimal, vice versa
• Binary to BCD, vice versa

Prepared by: Engr. Jerico P. Fiel


Bachelor of Science in Civil Engineering 4

Example 1: Convert 1010011 Binary Code to its equivalent BCD Code.


Solution: Convert binary to decimal digits first then decimal digits to BCD Code
Binary to Decimal
1 0 1 0 0 1 1
26*1 25*0 24*1 23*0 22*0 21*1 20*1
64*1 32*0 16*1 8*0 4*0 2*1 1*1
64 0 16 0 0 2 1
64+0+16+0+0+2+1=83
Decimal to BCD
8 3
1000 0011
1000+0011=10000011

1010011 Binary = 10000011 BCD

Example 2: Convert 1010011 BCD Code to its equivalent Binary Code.


Solution: Group the BCD Codes into 4-Bits starting from right then determine the
equivalent decimal digits
BCD to Decimal
101 0011
0101 0011
5 3
53
Decimal to Binary
53-25=53-32=21 (25 has a binary value of “1”)
21-24=21-16=5 (24 has a binary value of “1”)
5-22=5-4=1 (22 has a binary value of “1”)
1-20=1-1=0 (20 has a binary value of “1”)

Binary Code = 11011

SUMMARY

A binary code represents text, computer processor instructions, or any other data using a
two-symbol system. The two-symbol system used is often "0" and "1" from the binary
number system. The binary code assigns a pattern of binary digits, also known as bits, to
each character, instruction, etc. For example, a binary string of eight bits (which is also
called a byte) can represent any of 256 possible values and can, therefore, represent a
wide variety of different items.

REFERENCES

Books:
Mathematics in the Modern World, 14th Edition Aufman Richard, et. al.,,
Mathematics in the Modern World, Philippine Edition by REX Book Store
Mathematics in the Modern World, by Esmeralda A. Manlulu, et. al.

ISUI-CvE-Mod
Revision: 02
Effectivity: August 1, 2020

Prepared by: Engr. Jerico P. Fiel

You might also like