Write about concepts of Number Systems and the data representation in computers. | |||||||||||||||||||||||||||||||||||||||||||||||||||
As the computer is an electronic device, it works on the presence/absence of electronic signals. Electrical energy is used only to carry information. Computer uses a number system which is different from our usual decimal system for storing data. It can just recognize two states – ON or OFF and numbers are represented by using these two states i.e., by using the ON position to represent ‘1’ and the OFF position to represent ‘0’. Therefore, a number can be simulated easily within the computer under a number system which uses two digits only i.e, ‘0’ and ‘1’. This system is called Binary system. In decimal system we use 10 digits from 0 to 9. Each decimal ‘digit’ takes one of these ten values. The value depends on the ‘position’ of the number system i.e, units, tens, hundreds, thousands and so on. Binary Number system : The binary digits (0 and 1) are used to represent data in a computer. In computer terminology, the binary digit is called as a ‘bit’. As the computer works on electricity, the number 1 represents power on and 0 represents power off. Computers do not understand letters of decimal numbers. They only understand 1s and 0s. This is called the binary system. All the letters of the alphabet, all numbers and all signs like +, -, = etc are converted into 0s and 1s if the computer has to work with them. The positional value of each digit has to be the power of 2 i.e., 24 23 22 21 20 etc. (i.e., 16, 8, 4, 2, 1 etc.). The base of decimal system is 10 where as the base of binary system is 2. So this is also called ‘BASE2’ number system. The base of numbering system is called ‘Radix’. Therefore, the Radix of decimal system is 10 and that of binary system is 2. Decimal to binary conversion : The decimal number is successively by 2 (base of binary system) until division is no longer possible. At the end of each of successive division, the remainder is written in the next column. The binary equivalent of decimal number is obtained by writing the remainder from the bottom to the top. Example : Find the binary equivalent of Decimal Number 30.
Binary to decimal conversion : Write down the place value of binary numbers, multiply the place value with the number and add the result so obtained to get the value in decimal system. Example : Convert the binary number 1110010 to decimal.
We can also perform addition, subtraction, multiplication and division functions in binary system. The following examples illustrate them : Addition : Basic rule is – when we add two1’s the result is 0 with a carry digit.
Subtraction : This can be performed by using the process of addition by adding the complement of the number to be subtracted to the number from which subtraction is to be made. The complement is obtained by either using 1’s complement or 2’s complement. By using 1’s complement : 1’s complement is obtained by changing all the 0’s to 1’s and vice versa. Eg. 1’s complement of 10001 is 01110. The left most digit is treated as sign bit i.e, ‘0’ is +ve and ‘1’ is –ve. Procedure : a) Obtain the 1’s complement of the number which is to be subtracted b) Add the numbers and add the carry bit in the result. Example : Subtract 01000 (8 in decimal system) from 01100 (12 in decimal system) 1’s complement of 01000 : 10111 Now add 01100+10111 : 1 00011 (1 placed at distance is carry bit) Add carry bit : 1 ------- 00100 (4 in decimal system) ==== As the left most bit is ‘0’, the answer is ‘+ 4’ By using 2’s complement : 2’s complement is obtained by adding ‘1’ to the 1’s complement. Eg. 2’s complement of 10001 is 01111 (01110+1=01111) Procedure : a) Obtain 2’s complement of the number to be subtracted b) Add the numbers and neglect the carry bit. Example : Subtract 01000 (8 in decimal system) from 01100 (12 in decimal system) 2’s complement of 01000 is 10111+1 = 11000 Add 01100+11000 = 1 00100 (carry bit ‘1’ is neglected) As the left most digit is ‘0’, the answer is ‘+ 4’ (00100 = 4 in decimal system) Similarly, we can perform multiplication and division operations in binary system. Octal number system : The number system is based on 8 digits i.e., from 0 to 7. Therefore, it is called as Base-8 number system. This system is used by computer designers/engineers. We can get the octal equivalent of a decimal number by dividing the decimal number successively and remainders written from bottom to top. Eg. Octal equivalent of decimal number 135 = 207. Hexa-Decimal System : This number system is based on 16 elements. The first 10 digits form from 0 to 9 and the 11th to 16th elements are represented by A,B,C,D,E,F. Therefore 10 in decimal system is equal to A in hexa-decimal, 11 is B, 12 is C and so on. This systems is also known as Base-16 number system. This system is used by system designers.The equivalents of some decimal numbers in hexa decimal syster are as under : Decimal Hexa-decimal 26 1A 27 1B 28 1C 29 1D 30 1E 31 1F 32 20 Bits & Bytes : Each 1 or 0 that a computer understands is called a bit. A group of 8 bits is called a byte. All letters, digits and signs are stored in the computer as bytes. The standard by which all characters (numerals, alphabets, symbols) are represented by a combination of 1s and 0s is called ASCII (American Standard Code for Information Interchange). Computers all over the world understand characters written in ASCII format. A combination 8 bits is used for representing any single character in this system. Thus the system could provide a total of 28 = 256 unique combinations. Thus a table of 256 codes was prepared and the code was assigned to each character. The codes were numbered from 0 to 255. Earlier computers used the 8 bit word. Today’s computers use 16-bit to 64-bit words. Binary Coded Decimal (BCD) : Each decimal digit in a binary code is assigned a four-digit binary code to avoid the task of converting the numbers as a whole into binary. This code is known as BCD. This occupies more storage space than in pure binary system. Memory Storage : This is measured in bytes. · 1 kilobyte (KB) is equal to 1024 bytes · 1 Megabyte (MB) is equal to 1024 KB (10,48,576 bytes) · 1 Gigabyte (GB) is equal to 1024 MB (107,37,41,824 bytes) |