Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Document Details

IrreproachableByzantineArt

Uploaded by IrreproachableByzantineArt

Uttaranchal University, Dehradun

Tags

number systems binary arithmetic digital electronics computer science

Summary

This document is an introduction to number systems, focusing on binary arithmetic. It covers topics like binary numbers, arithmetic operations, and conversions between different number bases. Suitable for undergraduate-level computer science students.

Full Transcript

UNIT – 1 NUMBER SYSTEM STRUCTURE 1.0 Objectives 1.1 Introduction 1.2 Decimal numbers 1.3. Binary numbers 1.4. binary arithmetic 1.5. 1’ssand 2's Complements 1.6. octal numbers 1.7. Hexadecimal numbers 1.8. Inter-conversions of number systems 1.9. Let Us Sum Up 1.10. Key Words 1.11. Some...

UNIT – 1 NUMBER SYSTEM STRUCTURE 1.0 Objectives 1.1 Introduction 1.2 Decimal numbers 1.3. Binary numbers 1.4. binary arithmetic 1.5. 1’ssand 2's Complements 1.6. octal numbers 1.7. Hexadecimal numbers 1.8. Inter-conversions of number systems 1.9. Let Us Sum Up 1.10. Key Words 1.11. Some Useful Books 1.12. Answer to check your progress 1.13. Terminal Questions 1.0 OBJECTIVES After studying this unit, you will be able to: Define number system define binary operations Explain coding Describe binary arithmetic Know how to work with complements in number system Understand conversions of number system 1.1 INTRODUCTION Number systems use different number bases. A number base indicates how many different digits are available while using a particular numbering system. For example, decimal is number base 10, which means it uses ten digits: 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9. Binary is number base 2, which means that it uses two digits: 0 and 1. Different number bases are needed for different purposes. Humans use number base 10 whereas computers use binary. The number base determines how many digits are needed to represent a number. For example, the number 78 in decimal (base 10) requires two digits. The binary (base 2) equivalent is 1001110 which requires seven digits. As a consequence of this, there are many instances in computing very long binary numbers. To solve this problem, other number bases can be used, which require fewer digits to represent numbers. For example, some aspects of computing use number base 16 which is referred to as hexadecimal. 1.2 BINARY NUMBERS It is system based on powers of 2. The number system which uses only two digits 0 and 1 is called binary number system.0 or 1 is called as binary Digit or Bit The numbers represented by the digits 0 and 1 are the binary numbers. The base, i.e., radix of this system is 2. The position to the left or right of the binary point carry weights increasing or decreasing in power of 2 respectively. D4 D3 D2 D1 D0. D-1 D-2 D-3 D-4 24 23 22 21 20. 2-1 2-2 2-3 2-4 Table 1.1: Binary Digit Example: 0,1 Binary numbers are widely used in digital computers and digital communication because digital systems only understand the language of binary numbers 0 and 1. Also, it becomes easier to analyze and design digital circuits. For example: ON and OFF position of a switch presence or absence of hole in a card, set and reset positions of Bistable circuits, etc.; can be conveniently used to represent binary numbers. 1.3 BINARY ARITHMETIC Binary arithmetic includes the basic arithmetic operations of addition, subtraction, multiplication and division. The following sections present the rules that apply to these operations when they are performed on binary numbers. Binary Addition: Binary addition is performed in the same way as addition in the decimal- (A) Binary Addition Rules for Binary Addition Augend Addend Addition Result Sum Sum Carry 0 0 0 0 0 0 1 1 1 0 1 0 1 1 0 1 1 10 0 1 Table 1.2 Binary Addition arithmetical operations 1. 1100111 + 101101 1.1100111 + 101101 11 11 1 Carry 11 01 11 + 101101 11 00 10 0 Sum ] (B) Binary Subtraction Rules for Binary Subtraction Minuend Subtrahen Difference borrow d 0 0 0 0 0 1 1 1 1 0 1 0 1 1 0 0 Table 1.3: Binary Subtraction Subtract 1011 from 11010 1 1 01 0 minuend -0 1 01 1 Subtrahend 0 1 11 1 Difference (C) Binary Multiplication Multiply 1010 with 1101. Rules for binary multiplication Table 1.9: Binary Multiplication Multiplicant Multiplier Product 0 0 0 0 1 0 1 0 0 1 1 1 Example: 1010 × 1101 1010 0000× 01 01 0 (D) Binary Division Rules for binary division – It is same as decimal division. Example: Divide 100110001 by 1011 Divisor by Quotient 11 01 1 1011 1 0 0 1 1 0 0 0 1Quotient - 1011 Dividend 01 00 00 - 1011 00 01 01 00 - 1011 01 00 11 - 1011 01000 Remainder 1.4 1’S AND 2'S COMPLEMENTS (a) 1’s complement In a binary number, if each 1 is replaced by 0 and each 0 is replaced by 1, the resulting number is known as the 1’s complement of the first number. In fact, both the numbers are complement to each other. If one of these number is positive, then the other number will be negative with the same magnitude and vice versa. Example: (0101) represents (+5)10 where (1010) represents (-5)10 (b) 2’s complement of a binary number 2’s complement is obtained by adding 1 to 1’s complement of a binary number. 2’s complement method is used for subtraction operation in digital circuits with the use of 2’s complement representation for negative number, it is possible to use the circuit designed for binary addition for the purpose of binary subtraction also. Example (A) When Result is Positive (9) D = (1001)2 minuend (-7)D = (0111)2 substrend 0 1 1 1 1000 1’s complement of (0111)2 1001 2’s complement of (0111)2 (9)10 = (1001)2 (-7)D = + (1001)2 2’s complement of (0111)2 (2)D = 1 (0010)2 Discard final carry The answer is (0010)2 equivalent to (+2)10 (B) When Result is Negative (7)D = (0111)2 minuend (-9)D = - (1001)2 substrend 1 0 1’s complement of (1001)2 0110 + 1 0111 2’s complement of (1001)2 (7)D = (0111)2 (- = + (0111)2 9)D (-2)D= 1 1 1 0 The final carry = 0 Therefore, answer is negative and 2’s complement of 1110 is = 1’s complement of 1110 + 1 = 000 Subtraction using 2’s complement Binary subtraction can be performed by adding the 2’s complement of the subtracted to the minuend. 1. If the final carry is generated discard the carry and the remaining bit is the answer which is positive. 2. If the final carry is 0, the answer is negative and is in 2’s complement form. Example: (A) When Result is Positive (9)D = (1001)2 minuend (- = (0111)2 substrend 0 1 1 1 7)D 1 0 0 0 1’s complement of (0111)2 + 1 1 0 0 1 2’s complement of (0111)2 (9)10 = (1001)2 (-7)D = + (1001)2 2’s complement of (0111)2 (2)D = 1 (0010)2 Discard final carry The answer is (0010)2 equivalent to (+2)10 (D) When Result is Negative (7)D = (0111)2 minuend (-9)D = - (1001)2 substrend 10 01 0110 1’s complement of (1001)2 + 1 0111 2’s complement of (1001)2 (7)D = (0111)2 (-9)D = + (0111)2 (-2)D = 1 1 1 0 The final carry = 0 Therefore, answer is negative and 2’s complement of 1110 is = 1’s complement of 1110 + 1 = 0001 + 1= (0010)2 The answer is (-2)D 1.5 OCTAL NUMBERS Characteristics ⚫ Uses eight digits, 0, 1, 2, 3, 4, 5, 6, 7. ⚫ Also called base 8 number system. ⚫ Each position in an octal number represents a number power of the base 8. Example: 80, 81, 82, ---- -- The decimal, binary and octal equivalent numbers are shown below. Table 1.10: Octal Number Decimal Binary Octal 0 000 0 1 001 1 2 010 2 3 011 3 4 100 4 5 101 5 6 110 6 7 111 7 Example: (2345)8 = 2 × 83 +3 × 82 +4× 81 + 5 × 80 Other Examples: (2323.23476)8, (17675.4567)8, (2432145.214365)8 1.6 HEXADECIMAL NUMBERS Hexadecimal number system has 10 symbol (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F) Characteristics ⚫ Uses 10 digits and 6 letters. They are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. ⚫ Each letters represents numbers. A = 10, B = 11, C = 12, D = 13, E = 14, F = 15. ⚫ It is also called base 16 number system. The decimal, binary and hexadecimal equivalent numbers are shown below. Table 1.11: Hexadecimal Number Decimal Binary Hexadecim al 0 0000 0 1 0001 1 2 0010 2 3 0011 3 4 0100 4 5 0101 5 6 0110 6 7 0111 7 8 1000 8 9 1001 9 10 1010 A 11 1011 B 12 1100 C 13 1101 D 14 1110 E 15 1111 F 1.7 INTER-CONVERSIONS OF NUMBER SYSTEMS. a. Conversion from Any System to Decimal Number To convert a decimal number to binary, octal and hexadecimal numbers. In this number is to continually divide the number by its radix and with each division, write down the remainder. When read from bottom to top, the remainder will be the converted result. Decimal to Binary Numbers Example 1: Convert the decimal number 1310 to binary numbers. Solution: Divide 1310 by the system radix 2, which converting to binary. Therefore, 1310= 11012 Example 2: Convert decimal number 29 to binary numbers. Solution: Calculating binary equivalent numbers. Operatio Resul Remainder n t 29/2 14 1 14/2 7 0 7/2 3 1 3/2 1 1 1/2 0 1 Table 1.12: binary equivalent numbers 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). Therefore, 2910= 111012. Octal to Decimal Conversion The system radix of octal is 8, since any of the 8 values from 0 to 7 can be written as a single digit. Example 1: Convert 1268 to decimal numbers. Solution:Using the values of each column, (which in an octal integer are powers of 8) 1268 = (1 × 82) + (2 × 81) + (6 × 80) = 1 × 64 + 2 × 8 + 6 × 1 = 64 + 16 + 6 = 86 Therefore, 1268 = 8610. Example 2: Convert octal number 12570 to decimal number. Solution: Calculating decimal equivalent numbers Octal number Decimal number 125708 ((1 × 84) + (2 × 8 3 )+ (5 × 8 2 )+ (7 × 8 1 )+ (0 × 80))10 125708 (4096 + 1024 + 320 + 56 + 0)10 125708 549610 Table 1.13: decimal equivalent numbers Therefore, 125708 = 549610 Hexadecimal to Decimal Numbers Example 1: Convert b2d16 to numbers.decimal Solution: Calculating decimal equivalent numbers b2d16 = (b × 162) + (2 ×161)+ (d × 160) = (11 × 16 2 )+ (2 × 161) + (13× 160) = 2816 + 32 +13 = 286110 Therefore, b2d16 = 286110. b. Conversion from Any System to Decimal Number To convert a decimal number to binary, octal and hexadecimal numbers. In this number is to continually divide the number by its radix and with each division, write down the remainder. When read from bottom to top, the remainder will be the converted result. Decimal to Binary Numbers Example 1: Convert the decimal number 1310 to binary numbers. Solution: Divide 1310 by the system radix 2, which converting to binary. Therefore, 1310= 11012 Example 2: Convert decimal number 29 to binary number. Solution:Calculating binary equivalent numbers. Operation Result Remainder 29/2 14 1 14/2 7 0 7/2 3 1 3/2 1 1 ½ 0 1 Table 1.14: binary equivalent numbers The remainders have to be arranged in the reverse order so that the first remainder becomes the least significant digit and the last remainder becomes the most significant digit Therefore, 2910= 111012. Decimal to Octal Numbers Example 1: Convert the decimal number 8610to octal numbers. Solution: Divide 8610 by the system radix, which when converting to octal is 8. This gives the answer 10, with a remainder of 6. Continue dividing the answer by 8 and writing down the remainder until the answer is 0 Therefore, 8610= 126 Example 2: Convert decimal number 25 to octal number. Solution:Calculating decimal equivalent numbers. Operation Result Remainder 25/8 3 1 3/8 0 3 Table 1.15 decimal equivalent numbers Therefore, equivalent number is 2510 = 318 Decimal to Hexadecimal Numbers Example 1: Convert decimal numbers 286110 to hexadecimal numbers. Solution: Divide 286110 by the system radix 16. As some of the remainders may be greater than 9 and so require their alphabetic replacement and then convert them to hexadecimal. Therefore, 286110= b2d16 Example 2: Convert decimal number 2479 to hexadecimal number. Operation Result Remainder Equivalent remainder 2479/16 154 15 F 154/16 9 10 A 9/16 0 9 9 Table 1.16: hexadecimal number equivalent to decimal number Binary number into decimal, every binary bit is multiplied by 2’s power from right to left before decimal point, finally all the values are added to get the decimal equivalent. For fraction, the bit is multiplied by 2-n where, n is position of bit from left to right. Example: (110101.0111)2 = (?)10 = (1 × 25 + 1 × 24 + 0 × 23 + 1 × 22 + 0 × 21 + 1 × 2 0 )+ (0 × 2-1 + 1 × 2-2 + 1 × 2-3 + 1 × 2-4) = (32 + 16 + 0 + 4 + 0 + 1) + (0 + 0.25 + 0.125 + 0.0625) = (53.4375)10 (A) Conversion of Binary Number System to Other Number System Binary to Decimal Conversion To convert any binary number into decimal, every binary bit is multiplied by 2’s power from right to left before decimal point, finally all the values are added to get the decimal equivalent. for fraction, the bit is multiplied by 2-n where, n is position of bit from left to right. Example: (110101.0111)2 = (?)10 = (1 × 25 + 1 × 24 + 0 × 23 + 1 × 22 + 0 × 21 + 1 × 2 0 )+ (0 × 2-1 + 1 × 2-2 + 1 × 2-3 + 1 × 2-4) = (32 + 16 + 0 + 4 + 0 + 1) + (0 + 0.25 + 0.125 + 0.0625) = (53.4375)10 Binary to Octal Conversion Binary to octal conversion can be done by forming a group of three bits starting at the binary and then converting. Each group of three bits to its octal equivalent. O’s are added at each end if necessary. Example: (11.01)2 = (?)8 = (32)8 (11.01)2 = (32) Binary to Hexadecimal System. Binary to hexadecimal conversion can be done by forming a group of four bits starting at the binary and they converting each group of four bits to its hexadecimal equivalent 0’s are added at each end if necessary. Example: (110110. 011101)2 = (?)16 = (00110110. 01110100)2 = (36.74)16 (110110. 011101)2 = (36.74)16 c. Conversion of Octal Number System to Other Number System Octal to Binary Conversion Octal to binary conversion can be done by writing these digits binary equivalent to each octal digit and then combining all the resulting bits into a single binary number. Example: (?)2 (125)8 = = 1 (001) = 2 (010) = 5 (101) (125)8 (001 010 = 101)2 Octal to Hexadecimal Conversion Octal to hexadecimal conversion can be done by first convert octal number into binary number by writing its 3-bit binary equivalent. Then binary number convert into hexadecimal number by making it 4bit binary equivalent. Example: (273.45)8 = (?)16 (273.45)8 = (?)2 (273.45)8 = (010111011.100101)2 Now make group of 4 bit and write its hexadecimal equivalent = (000010111011. 10010100)2 = (?)16 = (0 bb. 94)16 (010111011. 100101)2 = (0bb.94)16 Therefore, (273.45)8 = (0bb.94)16 d. Conversion of Hexadecimal Number System to Other Number System Hexadecimal to Binary Conversion Hexadecimal to binary conversion can be done by writing four digits binary equivalent to each hexadecimal digit and then combining all the resulting bits into a single binary number. The table given below shows the basic hexadecimal digits and equivalent binary number. Example: (25c. 3af)16 = (?)2 (25c.3af)16 (001001011100. 001110101111)2 Hexadecimal to Octal Conversion Hexadecimal to octal conversion can be done by first convert hexadecimal number into binary number, write its 4 bit binary equivalent, then binary number converted into octal number, group 3 bit binary and write its hexadecimal equivalent. Example: (fe9.37d)16 (?)8 (fe9.37d)16 = (?)2 (fe9.37d)16 = (111111101001. 001101111101)2 Check Your Progress- 1 1. 1's complement of binary number 110010 is: (a) 001101 (b) 000001 (c) 11110 (d) 1110000........................................................................................................................................................................................................................................................................................................................................................................................................................................ 2. 2’s complement of 01000 is: (a) 1110 (b) 11000 (c) 11111 (d) 1111................................................................................................................................................................................................................................................................................................................................................................................................................................ 3. Define number system.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 1.8 LET US SUM UP A numeral system (or system of numeration) is a writing system for expressing numbers; that is, a mathematical notation for representing numbers of a given set, using digits or other symbols in a consistent manner. The number the numeral represents is called its value. A numeral system (or system of numeration) is a writing system for expressing numbers; that is, a mathematical notation for representing numbers of a given set, using digits or other symbols in a consistent manner. The same sequence of symbols may represent different numbers in different numeral systems. For example, “11” represents the number eleven in the decimal numeral system (used in common life), the number three in the binary numeral system (used in computers), and the number two in the unary numeral system (e.g., used in tallying scores). The number the numeral represents is called its value. 1.9 KEY WORDS Augend: the number to which another is added. Addend: a number which is added to another. Radix: the base of a system of numeration. LSB: least significant bit MSB: most significant bit Binary code: The most basic language a computer understands, it is composed of a series of 0s and 1s. The computer interprets the code to form numbers, letters, punctuation marks, and symbols. Bit: The smallest piece of computer information, either the number 0 or 1. In short they are called binary digits. 1.10 ANSWER TO CHECK YOUR PROGRESS Check your Progress 1 Refer 1 for Answer to check your progress- 1 Q 1A Refer 1 for Answer to check your progress- 1 Q 2 B Refer 1 for Answer to check your progress- 1 Q 3 A number system is defined as a system of writing to express numbers. It is the mathematical notation for representing numbers of a given set by using digits or other symbols in a consistent manner. It provides a unique representation of every number and represents the arithmetic and algebraic structure of the figures. 1.11 SOME USEFUL BOOKS 1. Jain, R.P. (2010).Modern Digital Electronics. New Del hi: Tata McGraw Hill Pub. Company. 2. Thomas L. Floyd. (2012). Digital Fundamentals. New Delhi: Universal Publishing House. 3. William H. Gothmann (1982).Digital Electronics: An Int roduction to Theory and Practice. New Delhi: Prentice Hall of India. 4. Malvino, A.P. (2010).Digital Principles and Application s. New Delhi:McGraw Hill International Editions.. 1.12 TERMINAL QUESTIONS 1. Define binary operations. 2. Explain coding. 3. Describe binary arithmetic with suitable examples. 4. Describe binary number system conversion. 5. Explain various types of codes..

Use Quizgecko on...
Browser
Browser