Moodle 1 WILLINGDON COLLEGE SANGLI ELECTRONICS (B. Sc.-I) Introduction to Number System
E L E C T R O N I C S Introduction to Number System and Codes Moodle developed By Dr. S. R. Kumbhar Department of Electronics Willingdon College Sangli For B. Sc. I Electronics, Physics & Computer Science Students
N U M B E R S Y S T E M - 2 CHAPTER - I NUMBER SYSTEM AND BOOLEAN ALGEBRA 1.1 INTRODUCTION The number system is a system in which an ordered set of digits is used to specify number. The system having digits 0 to 9 is called decimal system. In decimal system the base or radix is 10. The system having numbers 0 and 1 is called binary with radix 2. The system having numbers 0 to 7 is called octal system and its radix is 8. In the hexadecimal system the numbers are represented from 0 to 9 and A to F with hex as base. Digital system works on the binary system. In digital system BIT is abbreviated from Binary digit. Bit is the basic unit of memory with 0 and 1 digit. Some of the common number systems are binary, decimal, octal and hexadecimal out of which decimal number system is most familiar to us. These systems are mostly used in the digital circuits, computers and many logic circuits. Therefore digital systems are required to handle data in the form of numeric, alphabets or symbols. Such data must be converted in to binary format by using different types of codes such as BCD, ASCII, GRAY, etc. 1.2 Binary number system Binary number system is represented with radix or base of 2 with only 0 and 1 digits. This 0 and 1 digits are called binary digits. A binary number with group of four bits is called Nibble and a group of 8 bits is called Byte. Following chart shows the binary equivalent of decimal number. B I N A R Y D E C I M A L 0000 0 0001 1 0010 2 0011 3 0100 4 0101 5 0110 6 0111 7 1000 8 1001 9 In binary number system left most bit is called Most Significant Bit (MSB) and right most bit is called least significant bit (LSB). 2
N U M B E R S Y S T E M - 3 Example: 1 0 0 1 A. MSB LSB a) Sign of numbers: In binary number system negative numbers are represented by placing a signed bit in the left most position of number and is separated by a comma. A 0 in this position means positive while 1 means negative number. Thus + 7 10 means 0, 111 and - 7 10 means 1, 111. 1.3 Decimal number system: Decimal number system has 10 digits such as 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9 are required to express a number. The base or radix of this number system is the total number of digits used in the system. Decimal number system has base 10 (ten). In decimal number system individual digits of the number represents the coefficients of some power of (10). Example : (2186) 10 is expanded in powers as follows 2186 = 2 x 10 3 + 1 x 10 2 + 8 x 10 1 + 6 x 10 0 1.4 Octal number system Octal number system has a base or radix of 8. In the octal system there are eight symbols are used such as 0, 1, 2, 3, 4, 5, 6 and 7. Example : (56) 8, (21) 8, (77) 8, etc. The octal number system does not have the number larger than decimal 7. 1.5 Hexadecimal number system The hexadecimal number system (Hex) uses a base or radix of 16. This system uses a set of 16 unique symbols i.e. 0 to 9 decimal digits having the same significance in decimal number system and six symbols A, B, C, D, E and F which represents decimal 10, 11, 12, 13, 14 and 15 respectively. Example: ( A7) Hex, (10) Hex, (FA) Hex, (1B) Hex.. 1.6 1 s and 2 s complement 1 s Complement: 1 s complement of binary number is usually expressed by changing each 0 to 1 and each 1 to 0. Thus 1 s complement of 0111011 is 1000100 and 1 s complement of 011.1001 is 100.0110. 2 s complement: 2 s complement of binary number is usually obtained by adding 1 to the least significant bit of the 1 s complement of binary number. 2 s complement of 0110 = 1001 + 1 = 1010 2 s complement of 010.111 = 101.000 + 1 = 101.000 3
N U M B E R S Y S T E M - 4 Example: Perform the subtraction by 1 s complement a) 1 0 11 0 1 0 1 b) 11.011.00 10011.11 1011 1011 11011.00 11011.00-0101 = + 1010-10011.11 = + 01100. 00 --------- ------------- 10101 100111.00 1 Add carry 1 0110 00111.01 If the carry is not generated then the answer is negative and is in 1 s complement form. Perform the subtraction using 2 s complement a) 1001 0111 b) 111.10 011.11 In the subtraction using 2 s complement method first take the 2 s complement of the number to be subtracted by 1 s complement and adding 1 to the LSB of subtrahend. Then binary addition of two numbers is performed with dropping a carry, if generated. a) 1100-0111 1100 + 1001 (2 s complement of 0111) 10101 carry dropped 0101 = Answer a) 111.10-011.11 111.10 + 100.01 ( 2 s complement of 0111) 1011.11 carry dropped 011.11 = Answer If the carry is not generated then the answer is negative and is in 2 s complement form. i.e. = 0 with carry 1 Rules for binary subtraction 0-0 = 0 0-1 = 1 with borrow 1 1-0 = 1 1-1 = 0 1.7 Binary addition Rules for binary addition 0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 10 Perform the binary addition of the following numbers a) 11001 b) 0011.011 + 10010 + 1000.100 101011 1001.111 Perform the binary subtraction of the following numbers a) 101.10 b) 11000.110-100.01-00110.101 001.01 10010.001 4
N U M B E R S Y S T E M - 5 1.9Conversion of numbers 1.9.1 Binary to Octal conversion: Note: make a group of 3 bits from decimal point a) 10000111 2 to Octal b) 1011.1011 2 to Octal 010 000 111 001 011. 101 100 2 0 7 1 3. 5 4 = (207) 8 = (13.54) 8 1.9.2 Binary to Decimal conversion Binary number can be converted into its equivalent decimal number using weighted position method. a) Convert (111001.11) 2 to decimal equivalent. 1 1 1 0 0 1. 1 1 2 5 2 4 2 3 2 2 2 1 2 0. 2-1 2-2 = 1 x 2 5 + 1x 2 4 + 1 x 2 3 + 0 x 2 2 + 0x 2 1 + 1 x 2 0 +1x 2-1 + 1x 2-2 = 32 + 16 + 8 + 0 + 0 + 1 + 0.5 + 0.25 = (27.75) 10 b) Convert 11.011 to decimal equivalent. 1 1. 0 1 1 2 1 2 0. 2-1 2-2 2-3 = 1x 2 1 + 1 x 2 0 + 0 x 2-1 + 1x 2-2 + 1 x 2-3 = 2 + 1 + 0.0 + 0.25 + 0.125 = (3.375) 10 1.9.3 Binary to hexadecimal conversion a) Convert binary 1001100101 2 to hexadecimal number Note: make a group of 4 bits from decimal point and convert binary number into its decimal equivalent. a) 1001100101 2 b) 1011.1011 2 to Hex 0010 0110 0101 0011.1011 2 6 5 3. B = (265) Hex = (3.B) 8 C) Convert 11100111110.11110110 to Hexadecimal 0111 0011 1110. 1111 0110 7 3 E. F 6 = (73E.F6) Hex 1.9.4 Conversion of octal to binary 1) Convert (2176) 8 to Binary. 2 1 7 6 010 001 111 110 5
N U M B E R S Y S T E M - 6 2) Convert (0.75) 8 to Binary. 3) Convert 335.34 to binary 0. 7 5 3 3 5. 3 4 0000. 0111 0101 011 011 101. 011 100 = 0.01110101 2 = (11011101.011100) 2 1.9.5 Octal to decimal converter a) convert (315.1) to decimal b) Convert (724) to decimal 3 1 5. 1 3 8 5 8 2 8 1 8 0. 8-1 8 2 8 1 8 0 3 x 8 2 + 1x 8 1 + 5 x 8 0 + 8-1 8 2 x 3 + 8 x 8 1 + 5x 8 0 = 192 + 8 + 5 + 0.15 192 + 64 + 5 = (210.15) 10 = (261) 10 1.9.6 Octal to Hexadecimal converter 1) Convert (63.5) 8 to hexadecimal Convert it into group of four digits from the decimal point. 6 3. 5 110 011. 110 By making group of 4 digits 0011 0011. 1100 1.9.7 Decimal to binary 3 3. C = (33. C) Hex For integers divide successively by 2, by writing quotient and its reminder till zero. The reminder is taken in reverse order. a) Convert decimal 15 to binary 15 2 = 7 1 LSB 7 2 = 3 1 = (1111) 2 3 2 = 1 1 1 2 = 0 1 MSB B) Convert decimal 29.8125 to binary Note : For fraction multiply given number by 2, record the carry till quotient becomes zero and then represent the binary number in downward direction. 29 2 = 14 1 LSB 0.8125 x 2 = 1.6250 1 14 2 = 7 0 0.6250 x 2 = 1.2500 1 7 2 = 3 1 0.2500 x 2 = 0.5000 0 3 2 = 1 1 0.500 x 2 = 1.000 1 1 2 = 0 1 MSB = (11101 1101) 2 1.9.8 Convert decimal to Octal While converting decimal to octal, divide the number by 8 successively and note down the reminder in reverse order. Similarly fractional numbers are multiplied by 8 and carry is recorded. 6
N U M B E R S Y S T E M - 7 a) Convert (543.403) to octal 543 8 = 67 7 LSB 0.403 x 8 = 3.224 3 67 8 = 8 3 0.224 x 8 = 1.792 1 8 8 = 1 1 0.792 x 8 = 6.336 6 1 8 = 0 1 MSB 0.336 x 8 = 2.688 2 0.688 x 8 = 5.504 5 = (1137. 31625) 8 b) Convert (550.550) to octal 550 8 = 68 6 LSB 0.55 x 8 = 4.4 4 68 8 = 8 4 0.4 x 8 = 3.2 3 8 8 = 1 1 0. 2 x 8 = 1.6 1 1 8 = 0 1 MSB 0.6 x 8 = 4.8 4 0.4 x 8 = 3.2 3 Reoccurring = (1146. 43143) 8 1.9.9 conversion of decimal to hexadecimal a) Convert (2171. 10) to hexadecimal 2171 16 = 135 B LSB 0.1 x 16 = 1.6 1 135 16 = 8 7 0.6 x 16 = 9.6 9 8 16 = 0 8 MSB 0. 6 x 16 = 9.6 9 Reoccurring = (87B.199) Hex b) Convert (3219.10) to hexadecimal 3219 16 = 202 7 LSB 0.1 x 16 = 1.6 1 202 16 = 12 A 0.6 x 16 = 9.6 9 12 16 = 0 C MSB 0. 6 x 16 = 9.6 9 Reoccurring = (CA7.199) Hex 1.9.10 conversion of hexadecimal to binary a) convert (D0C) Hex to binary and b) (BC.B3C) to binary a) D 0 C b) B C. B 3 C 1101 0000 1100 1011 1100. 1011 0011 1100 = (110100001100) 2 = (10111100. 101100111100) 2 1.9.11 conversion of hexadecimal to Octal First convert the given hexadecimal number into binary and then make the group of three bits from the decimal point and write the corresponding octal number a) Convert (CAB) Hex to Octal C A B Hexadecimal number 1100 1010 1011 Binary number (110 010 101 011) 2 Binary 3 digit groups 6 2 5 3 = (6253) 8 Octal number 7
N U M B E R S Y S T E M - 8 a) Convert (BA. 1B) Hex to Octal B A. 1 B Hexadecimal number 1011 1010 0000 1011 Binary number (1 011 101 000 001 011) 2 Binary 3 digit groups 1 3 5 0 1 3 = (135013) 8 Octal number 1.9.12 conversion of hexadecimal to Octal a) Convert (150) Hex to decimal 1 5 0 16 2 16 1 16 0 = 1x 16 2 + 5 x 16 1 + 0 x 16 0 = 256 + 80 + 0 = (336) Hex B) Convert (18B. 88) Hex to decimal 1 8 B. 8 8 16 2 16 1 16 0 16-1 16-2 = 1x 16 2 + 8 x 16 1 + B x 16 0 + 8 x 16-1 + 8 x 16-2 = 256 +128 + B + 0.5 + 0.032 = (395.532) Hex 8