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/ 45
BINARY NUMBER SYSTEMS AND
CODE
CHARITO B. TAGUBA, MIT
INSTRUCTOR LEARNING OBJECTIVES AT THE END OF THE SESSION, YOU WILL BE ABLE TO:
• identify and describe various number systems;
• compare base-10 to a binary system; • apply conversion of binary to BCD and excess 3; and • convert Excess 3 to binary and BCD. WHAT ARE BINARY NUMBERS?
• BinaryNumbers are the flow of information in the
form of zeros and ones used by digital computers and systems. Computers work on the principle of number manipulation. Inside the computer, the numbers are represented in bits and bytes. •A logic “1” represents a higher voltage, such as 5 volts, which is commonly referred to as a HIGH value, while a logic “0” represents a low voltage, such as 0 volts or ground, and is commonly referred to as a LOW value. BITS
•: BInary digiTS, and in digital and computational
circuits and applications they are normally referred to as binary BITS • two discrete voltage levels representing the digital values of “1’s” (one’s) and “0’s” (zero’s). BINARY BITS OF ZEROS AND ONES ANALOGUE CIRCUITS • Analogue or Linear circuits amplify or respond to continuously varying voltage levels that can alternate between a positive and negative value over a period of time DIGITAL CIRCUITS
• Digital circuits produce or respond too two distinct
positive or negative voltage levels representing either a logic level “1” or a logic level “0”. ANALOGUE VOLTAGE OUTPUT REPRESENTATION DIGITAL VOLTAGE OUTPUT REPRESENTATION Then we can see that the major difference between an analogue signal or quantity and a digital quantity is that an “Analogue” quantity is continuously changing over time while a “Digital” quantity has discrete (step by step) values. “LOW” to “HIGH” or “HIGH” to “LOW”. DECIMAL VALUES AND BINARY EQUIVALENTS CHART BINARY NUMBERS • can be added together and subtracted just like decimal numbers with the result being combined into one of several size ranges depending upon the number of bits being used. Binary numbers come in three basic forms – a bit, a byte and a word, where a bit is a single binary digit, a byte is eight binary digits, and a word is 16 binary digits. THE CLASSIFICATION OF INDIVIDUAL BITS INTO LARGER GROUPS ARE GENERALLY REFERRED TO BY THE FOLLOWING MORE COMMON NAMES OF: • Today, as micro-controller or microprocessor systems become increasingly larger, the individual binary digits (bits) are now grouped together into 8’s to form a single BYTE with most computer hardware such as hard drives and memory modules commonly indicate their size in Megabytes or even Gigabytes. BINARY CODED DECIMAL OR BCD • is another process for converting decimal numbers into their binary equivalents. do not get confused, binary coded decimal is not the same as hexadecimal. Whereas a 4-bit hexadecimal number is valid up to F16 representing binary 11112, (decimal 15), binary coded decimal numbers stop at 9 binary 10012. This means that although 16 numbers (24) can be represented using four binary digits. • 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. BINARY CODED DECIMAL TABLE ADVANTAGES OF BINARY CODE •• 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. 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. CLASSIFICATION OF BINARY CODES • • Weighted Codes • • Non-Weighted Codes • • Binary Coded Decimal Code • • Alphanumeric Codes • • Error Detecting Codes • • Error Correcting 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 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. WEIGHTED CODES 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. EXAMPLE: 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 has 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. GRAY CODE 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. 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 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. • Error Codes • There are binary code techniques available to detect and correct data during data transmission. • 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 BCD Conversion • BCD to Binary Conversion • BCD to Excess-3Excess-3 to BCD •Binary to BCD Conversion • Steps • • Step 1 -- Convert the binary number to decimal. • • Step 2 -- Convert decimal number to BCD. • Example: convert (11101)2 to BCD. • Step 1 - Convert to Decimal • Binary Number: 111012 • Calculating Decimal Equivalent: • • Step Binary Number Decimal Number • Step 1 111012 ((1 x 24) + (1 x 23) + (1 x 22) + (0 x 21) + (1 x 20))10 • Step 2 111012 (16 + 8 + 4 + 0 + 1)10 • Step 3 111012 2910 • • Binary Number: 111012 = Decimal Number: 2910 • STEP 2 - CONVERT TO BCD • • Decimal Number: 2910 • Calculating BCD Equivalent. Convert each digit into groups of four binary digits equivalent. • Step Decimal Number Conversion • Step 1 2910 00102 10012 • Step 2 2910 00101001BCD • Result : 111012 = 00101001BCD • BCD to Binary Conversion • Steps • • Step 1 -- Convert the BCD number to decimal. • • Step 2 -- Convert decimal to binary. • Example: convert (00101001)BCD to Binary. • STEP 1 - CONVERT TO BCD • BCD Number: 00101001BCD • Calculating Decimal Equivalent. Convert each four digit into a group and get decimal equivalent or each group. • StepBCD Number Conversion • Step 1 00101001BCD 00102 10012 • Step 2 00101001BCD 210 910 • Step 3 00101001BCD 2910 • • BCD Number: 00101001BCD = Decimal Number: 2910 • STEP 2 - CONVERT TO BINARY • • Used long division method for decimal to binary conversion. • Decimal Number: 2910 • Calculating Binary Equivalent: • Step Operation Result Remainder • Step 1 29 / 2 14 1 • Step 2 14 / 2 7 0 • Step 3 7/2 3 1 • Step 4 3/2 1 1 • Step 5 1/2 0 1 • Asmentioned in Steps 2 and 4, the remainders have to be arranged in the reverse order so that the first remainder becomes the least significant digit (LSD) and the last remainder becomes the most significant digit (MSD). • • Decimal Number: 2910 = Binary Number: 111012 • Result : 00101001BCD = 111012 • BCD to Excess-3 • Steps •• Step 1 -- Convert BCD to decimal. •• Step 2 -- Add (3)10 to this decimal number. •• Step 3 -- Convert into binary to get excess-3 code. • Example: Convert 1001BCD to Excess-3. • • STEP 1 - CONVERT TO DECIMAL • 1001BCD = 9 • STEP 2 - ADD 3 TO DECIMAL • 910 + 310 = 1210 • STEP 3 - CONVERT TO EXCESS-3 • 1210 = 11002 • Result : 1001BCD = 1100XS-3 • Steps • 1. Step 1 -- Subtract 00112 from each 4 bit of excess-3 digit to obtain the corresponding BCD code. • Example: convert 10011010XS-3 to BCD. • Given XS-3 number = 1001 1010 • Subtract 00112 = 0011 0011 • -------------------- • BCD = 0 1 1 0 0 1 1 1 • Result : 10011010XS-3 = 01100111BCD M A B B A L O! ! !