Introduction The term digital is derived from the way computers perform operation, by counting digits. Application of digital technology: television, communication systems, radar, navigation and guidance system, military system, medical instrument, industrial process control and etc. www.educlash.com
Digital and Analog Quantities Analog quantities have continuous values Digital quantities have discrete sets of values Analog : a quantity represented by voltage, current or meter movement that is proportional to the value of that quantity Digital : the quantities are represented not by proportional quantities but by symbols called digits www.educlash.com
Digital and Analog Quantities Digital quantities have discrete sets of values Analog quantities have continuous values www.educlash.com
Advantages of Digital Systems Over Analog Systems More reliable than analog systems due to better immunity to noise & better accuracy. Ease of design: No special math skills needed to visualize the behavior of small digital (logic) circuits. Programmability. Speed: A digital logic element can produce an output in less than 10 nanoseconds (10-8 seconds). Economy: Due to the integration of millions of digital logic elements on a single miniature chip forming low cost integrated circuit (ICs). www.educlash.com
Binary Digits The conventional numbering system uses ten digits: 0,1,2,3,4,5,6,7,8, and 9. The binary numbering system uses just two digits: 0 and 1. The two binary digits are designated 0 and 1 They can also be called LOW and HIGH, where LOW = 0 and HIGH = 1 www.educlash.com
Logic Level www.educlash.com
Number Systems, Operations and Codes www.educlash.com
Introduction The binary system and digital codes are fundamental to computers and to digital electronic in general. The binary number system such as decimal, hexadecimal and octal is presented. Arithmetic operations with binary numbers are covered to provide a basis for understanding how computers and many other types of digital systems work. www.educlash.com
Number System Decimal Binary Octal Hexadecimal 0 ~ 9 0 ~ 1 0 ~ 7 0 ~ F www.educlash.com
Decimal Numbers In decimal number system each of the ten digits, 0 through 9 Example: Express the decimal number 2745.214 as a sum of the values of each digit www.educlash.com
Binary Numbers The binary number system is another way to represent quantities. There are 1 (HIGH) and 0 (LOW) The binary numbering system has a base of 2 with each position weighted by a factor of 2: www.educlash.com
Example Convert the binary whole number 1101101 to decimal Try This: 1111001 Solution: Weight: 26 25 24 23 22 21 20 Binary : 1 1 0 1 1 0 1 1101101 = 26 + 25 + 23 + 22 + 20 = 64 + 32 + 8 + 4 + 1 = 109 www.educlash.com
Decimal Number Binary Number 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 22 21 20 0 0 0 0 0 1 0 2 0 0 2 1 4 0 0 4 0 1 4 2 0 4 2 1 23 22 21 20 8 0 0 0 8 0 0 1 8 0 2 0 8 0 2 1 8 4 0 0 8 4 0 1 8 4 2 0 8 4 2 1 www.educlash.com
Illustration of a Simple Binary Counting Application An Application Illustration of a Simple Binary Counting Application www.educlash.com
Decimal-to-Binary Conversion Sum-of-Weight Method Repeated Division by 2 Method Converting Decimal Fractions to Binary www.educlash.com
Sum-of-Weight Method 1 0 0 1 Example: 1 0 0 1 Example: Convert the following decimal numbers to binary: a) 12 b) 25 c) 58 d) 82 The decimal number 9, for example, can be expressed as the sum of binary weight of: 1100 11001 111010 1010010 www.educlash.com
Repeated Division by 2 Method A systematic method of converting whole numbers from decimal to binary is the repeated division-by-2 process. Remainder Example Convert the decimal number 12 to binary MSB LSB Stop when the whole-number quotient is 0 Convert decimal number 39 to binary? www.educlash.com
Converting Decimal Fractions to Binary Sum-of-Weight 0.625 = 0.5 + 0.125 = 2-1 + 2-3 = 0.101 Repeated Multiplication by 2 MSB LSB Carry . 1 0 1 0.625 x 2 = 1.25 0.25 x 2 = 0.50 0.50 x 2 = 1.00 1 Stop when the fractional part is all zeros www.educlash.com
Binary Arithmetic Binary arithmetic is essential in all digital computers and in many other types of digital systems. Addition, Subtraction, Multiplication, and Division www.educlash.com
Binary Addition Example: The four basic rules for adding binary digits (bits) are as follows: 0 + 0 = 0 sum of 0 with a carry of 0 0 + 1 = 1 sum of 1 with a carry 0f 0 1 + 0 = 1 sum of 1 with a carry of 0 1+ 1 = 10 sum of 0 with a carry 0f 1 1 1 0 1 1 + 0 0 1 1 0 0 Carry Example: Try This: 11 + 11 = ?? www.educlash.com
Binary Subtraction Example: The four basic rules for subtracting bits are as follows: 0 – 0 = 0 1 – 1 = 0 1 – 0 = 1 10 – 1 = 1 0 – 1 with a borrow of 1 1 1 – 0 1 = ?? 1 1 0 1 1 0 Example: Try This: 1 0 1 – 0 1 1 = ??? www.educlash.com
Binary Multiplication The four basic rules for multiplying bits are as follows: 0 X 0 = 0 0 X 1 = 0 1 X 0 = 0 1 X 1 = 1 1 1 X 1 1 = ?? 1 1 X 1 1 +1 1 1 0 0 1 Try This: 1 1 1 X 1 0 1 = ?? Example: www.educlash.com
Binary Division Example: Division in binary follows the same procedure as division in decimal. 1 1 0 ÷ 11 = ?? 1 0 11 1 1 0 1 1 0 0 0 Example: Try This: 1 1 0 ÷ 10 = ?? www.educlash.com
1’s and 2’s Complements of Binary Numbers The 1’s and 2’s Complements of Binary Numbers are very important because they permit the representation of negative numbers. The method of 2’s compliment arithmetic is commonly used in computers to handle negative numbers www.educlash.com
Finding the 1’s Complement The 1’s complement of a binary number is found by changing all 1s to 0s and all 0s to 1s. Example: 1 0 1 1 0 0 1 0 (Binary Number) 0 1 0 0 1 1 0 1 (1’s Complement) NOT Gate www.educlash.com
Finding the 2’s Complement The 2’s complement of a binary number is found by adding 1 to the LSB of the 1’s complement 2's Complement = (1's Complement) + 1 Find the 2’s complement of 10110010 10110010 (Binary number) + 01001101 (1’s complement) 1 (Add 1) 01001110 Example: www.educlash.com
Alternative Method to find 2’s Complement Start at the right with the LSB and write the bits as they are up and including the first 1 Take the 1’s complements of the remaining bits 10111000 (Binary Number) 01001000 (2’s Complement) Try This: 10010001 Example: These bits stay the same 1’s Complements of original bits 01101111 www.educlash.com
Signed Numbers Digital systems, such as the computer, must be able to handle both positive and negative numbers. A signed binary number consists of both sign and magnitude information. The sign indicates whether a number is positive or negative and the magnitude is the value of the number. There three forms in which signed integer (whole) numbers can be represented in binary: Sign-Magnitude 1’s Complement 2’s Complement www.educlash.com
0 = Positive Number and 1 = Negative Number The Sign Bit The left-most bit in a signed binary number is the sign bit, which tells you whether the number is positive or negative. 0 = Positive Number and 1 = Negative Number Sign-Magnitude Form When a signed binary number is represented in sign-magnitude, the left-most bit is the sign bit and the remaining bits are the magnitude bits. The magnitude bits are in true (uncomplemented) binary for both positive and negative numbers. Decimal number, +25 is expressed as an 8-bit signed binary number using sign-magnitude form as: 00011001 Example: Magnitude Bit Sign Bit www.educlash.com
1’s Complement Form Positive numbers in 1’s complement form are represented the same way as the positive sign-magnitude numbers. Negative numbers, however, are the 1’s complements of the corresponding positive numbers. Example: The decimal number -25 is expressed as the 1’s complement of +25 (00011001) as (11100110) 2’s Complement Form In the 2’s complement form, a negative number is the 2’s complement of the corresponding positive number www.educlash.com
Example: Sign-Magnitude: 1's Complement: 2's Complement: 00100111 Express the decimal number -39 in sign-magnitude, 1’s complement and 2’s complement 00100111 Sign-Magnitude: 00100111 >>> 10100111 1's Complement: 00100111 >>> 11011000 2's Complement: 00100111 >>> 11011001 www.educlash.com
The Decimal Value of Signed Numbers Decimal Value of positive and negative numbers in the sign-magnitude form are determined by summing the weights in all the magnitude bit positions where there are 1s and ignoring those positions where there are zeros. Sign-Magnitude: Determine the decimal value of this signed binary number expressed in sign magnitude: 1 0 0 1 0 1 0 1 Example: 26 25 24 23 22 21 20 0 0 1 0 1 0 1 >> 16 + 4 + 1 = 21 The sign bit is 1: Therefore, the decimal number is -21 www.educlash.com
The Decimal Value of Signed Numbers 1’s Complement: Decimal values of negative numbers are determined by assigning a negative value to the weight of the sign bit, summing all the weight where there are 1s and adding 1 to the result Determine the decimal values of this signed binary numbers expressed in 1’s complement Example: 00010111 11101000 -27 26 25 24 23 22 21 20 -27 26 25 24 23 22 21 20 0 0 0 1 0 1 1 1 1 1 1 0 1 0 0 0 16 + 4 + 2 + 1 = +23 -128 + 64 + 32 + 8 = -24 + 1 = -23 www.educlash.com
The Decimal Value of Signed Numbers The weight of the sign bit in a negative number is given a negative value 2’s Complement: Determine the decimal values of this signed binary numbers expressed in 1’s complement Example: 01010110 10101010 -27 26 25 24 23 22 21 20 -27 26 25 24 23 22 21 20 0 1 0 1 0 1 1 0 1 0 1 0 1 0 1 0 64 + 16 + 4 + 2 = +86 -128 + 32 + 8 + 2 = -86 www.educlash.com
Arithmetic Operations with Signed Number In this section we will learn how signed numbers are added, subtracted, multiplied and divided. This section will cover only on the 2’s complement arithmetic, because, it widely used in computers and microprocessor-based system . www.educlash.com
Addition 0 0 0 0 0 1 1 1 +0 0 0 0 0 1 0 0 Both Number Positive: 7 + 4 0 0 0 0 1 0 1 1 The Sum is Positive and is therefore in true binary Positive Number with Magnitude Larger than Negative Number: Discard Carry 0 0 0 0 1 1 1 1 +1 1 1 1 1 0 1 0 15 + (-6) 1 0 0 0 0 1 0 0 1 The Final Carry is Discarded. The Sum is Positive and is therefore in true binary www.educlash.com
Addition 0 0 0 1 0 0 0 0 +1 1 1 0 1 0 0 0 Negative Number with +1 1 1 0 1 0 0 0 Negative Number with Magnitude Larger than Positive Number: 16 + (-24) 1 1 1 1 1 0 0 0 The Sum is Negative and is therefore in 2’s complement form Discard Carry 1 1 1 1 1 0 1 1 + 1 1 1 1 0 1 1 1 Both Number Negative: -5 + (-9) 1 1 1 1 1 0 0 1 0 The Final Carry is Discarded. The Sum is Negative and is therefore in 2’s complement form www.educlash.com
Subtraction Example: Solution: To subtract two signed numbers, take the 2’s Complement of the subtrahend and ADD. Discard any final carry bit Example: 0 0 0 0 1 0 0 0 - 0 0 0 0 0 0 1 1 8 – 3 = 8 + (-3) = 5 Solution: 0 0 0 0 1 0 0 0 1 1 1 1 1 1 0 1 0 0 0 0 0 1 0 1 + 2’s Complement 1 Discard Cary Difference www.educlash.com
Multiplication Direct Addition: Partial Product: The numbers in a multiplication are the multiplicand, the multiplier and the product. Direct Addition and Partial Products are two basic methods for performing multiplication using addition. Direct Addition: 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 1 0 0 0 8 X 3 = 24 + 8 + 8 + 8 = 24 (Decimal) + Partial Product: Standard Procedure www.educlash.com
Division The division operation in computers is accomplished using subtraction. Since subtraction is done with an adder, division can also be accomplished with an adder. The result of a division is called the quotient. Step 1: Determine the SIGN BIT for both DIVIDEND and DIVISOR Step 2: Subtract the DIVISOR from the DIVIDEND using 2’s Complement addition to get the first partial remainder and ADD 1 to quotient. If ZERO or NEGATIVE the division is complete. Step 3: Subtract the divisor from the partial remainder and ADD 1 to the quotient. If the result is POSITIVE repeat Step 2 or If ZERO or NEGATIVE the division is complete. www.educlash.com
Hexadecimal Numbers Most digital systems deal with groups of bits in even powers of 2 such as 8, 16, 32, and 64 bits. Hexadecimal uses groups of 4 bits. Base 16 16 possible symbols 0-9 and A-F Allows for convenient handling of long binary strings. www.educlash.com
Hexadecimal Numbers Convert from hex to decimal by multiplying each hex digit by its positional weight. Example: www.educlash.com
Hexadecimal Numbers Convert from decimal to hex by using the repeated division method used for decimal to binary and decimal to octal conversion. Divide the decimal number by 16 The first remainder is the LSB and the last is the MSB. Note, when done on a calculator a decimal remainder can be multiplied by 16 to get the result. If the remainder is greater than 9, the letters A through F are used. www.educlash.com
Hexadecimal Numbers Example of hex to binary conversion: www.educlash.com
Hexadecimal Numbers www.educlash.com
Hexadecimal Numbers Hexadecimal is useful for representing long strings of bits. Understanding the conversion process and memorizing the 4 bit patterns for each hexadecimal digit will prove valuable later. www.educlash.com
BCD Binary Coded Decimal (BCD) is another way to present decimal numbers in binary form. BCD is widely used and combines features of both decimal and binary systems. Each digit is converted to a binary equivalent. www.educlash.com
BCD To convert the number 87410 to BCD: 8 7 4 8 7 4 1000 0111 0100 = 100001110100BCD Each decimal digit is represented using 4 bits. Each 4-bit group can never be greater than 9. Reverse the process to convert BCD to decimal. www.educlash.com
BCD BCD is not a number system. BCD is a decimal number with each digit encoded to its binary equivalent. A BCD number is not the same as a straight binary number. The primary advantage of BCD is the relative ease of converting to and from decimal. www.educlash.com
Alphanumeric Codes Represents characters and functions found on a computer keyboard. ASCII – American Standard Code for Information Interchange. Seven bit code: 27 = 128 possible code groups Table 2-4 lists the standard ASCII codes Examples of use are: to transfer information between computers, between computers and printers, and for internal storage. www.educlash.com
Thank You “ Buku yang selalu dibaca tidak akan mengumpul habuk dan debu. Berjinaklah dengan buku kerana ia adalah teman yang paling berguna menimba ilmu “ www.educlash.com