<<

Delhi Public School, R.K.Puram

Number Systems Decimal and Binary Systems Till now, you have been using Decimal number system in your mathematics. In Decimal number system, we have 10 digits that vary from 0 to 9.

Computers use electronic components, which do not use decimal number systems for internal operations. It uses a number system, which is known as system, in which digits vary from 0 to 1 only. It means a binary number contains no digit other than 0 and 1. Here, 0 represents OFF/False signal and 1 represents ON/True signal. Thus of decimal number system used by us in are converted into their equivalent binary values to be understood by the electronic components of the computer system.

The number 0 in decimal is 0 in binary, 1 in decimal is 1 in binary, 2 in decimal is 10 in binary, 3 in decimal is 11 in binary...

Now, let us see how we convert an value of a number in Decimal number system into a Binary number system.

(123)10 = ( )2 Note: Here, the subscript 10 represents base 10 of decimal number and subscript 2 represents base 2 of binary number.

To convert this number, we start dividing the decimal number by 2 and repeat the process with the of the , till we get 1 as quotient and then collect the remainders of all the divisions in the reverse order. Example: Decimal to Binary Base Quotient Remainder

2 123 1

2 61 1

2 30 0

2 15 1

2 7 1

2 3 1

1 So, the number equivalent to decimal number 123 will be 1111011 in binary. Now, if we want to obtain a decimal number equivalent to a binary number, we will use the following method.

Σ BasePosition * Place Value Position=0 Example: Binary to Decimal

(101011)2 = ( )10 5 4 3 2 1 0 (101011)2 = (2 * 1) + (2 * 0) + (2 * 1) + (2 * 0) + (2 * 1) + (2 * 1) = 32 + 0 + 8 + 0 + 2 + 1

= 43 and so,(101011)2 = (43)10 Number System Now, look at a very large binary number 1011101110110110 Can you remember this number for a long time, your answer will be obviously no and so the mathematicians thought, why not make some number system to interpret binary numbers for easy memorisation and they grouped three binary digits together to represent a number and so each digit

Number System CScXI/2013_2014/MK_MD/13 #1

Delhi Public School, R.K.Puram Computer Science of this new representation had a variation from 0 to 7 (i.e. 8 in total) - this new representation of number was called Octal number (with base 8). Look at the following table, which shows binary and its equivalent octal digits. Binary (In groups of 3) Octal

000 0

001 1

010 2

011 3

100 4

101 5

110 6

111 7 Example: Binary to Octal

(1010110)2 = ( )8 (1010110)2 = ( 1 010 110)2 Make groups of 3 starting from the right side = (001 010 110)2 Add required number of 0s before the first group to make it a group of 3 bits = (126)8 Interpret each group as single octal digit & you get the octal number equivalent

Reverse of this conversion can also be done in the same way

(237)8 = ( )2 (237)8 = ( 2 3 7 )8 Write all digits separately = ( 010 011 111 )2 Interpret single octal digit as binary equivalent Number System Further to octal numbers, a grouping of 4 Binary digits of a binary number gave birth to Hexadecimal Number system. Here, each digit of this new representation had a variation from 0 to 15 (i.e. 16 in total). Look at the following table, which shows Binary and its equivalent Hexadecimal digits. Binary (In groups of 4) Hexadecimal Remarks

0000 0

0001 1

0010 2

0011 3

0100 4

0101 5

0110 6

0111 7

1000 8

1001 9

Number System CScXI/2013_2014/MK_MD/13 #2

Delhi Public School, R.K.Puram Computer Science

1010 A Representing 10

1011 B Representing 11

1100 C Representing 12

1101 D Representing 13

1110 E Representing 14

1111 F Representing 15

Example: Binary to Hexadecimal

(1011010110)2 = ( )16 (1011010110)2 = (10 1101 0110)2 Make groups of 4 digits = (0010 1101 0110)2 Add 0 before the first group as it is not a complete group = (2D6)16 Interpret each group as single Hexadecimal digit Reverse of this conversion can also be done in the same way

(2B7)16 = ( )2 (2B7)16 = ( 2 B 7 )16 Write all digits separately = ( 0010 1011 0111 )2 Interpret single hexadecimal digit as binary equivalent To obtain Decimal number from Octal or Hexadecimal number system, you have to use the same method as used while converting Binary to Decimal.

Σ BasePosition * Place Value Position=0 Example: Octal to Decimal

(126)8 = ( )10 2 1 0 (126)8 = (8 * 1) + (8 * 2) + (8 * 6) = 64 + 16 + 6

= 86 and so,(126)8 = (86)10

Example: Hexadecimal to Decimal

(1B6)16 = ( )10 2 1 0 (1B6)16 = (16 * 1) + (16 * 11) + (16 * 6) Note: B represents 11 = 256 + 176 + 6

= 438 and so,(1B6)16 = (438)10

Now, if you want to obtain octal or hexadecimal number from decimal number, you have to use the same method as used while converting decimal to binary.

For decimal to octal conversion we start dividing the decimal number by 8 and repeat the process with the quotient of the division, till you get a quotient which cannot be further divided by 8 and then collect the remainders of all the divisions in the reverse order. Example: Decimal to Octal Base Quotient Remainder

8 123 3

8 15 7

1

So, the number equivalent to decimal number 123 will be 173 in octal.

Similarly, for Decimal to Hexadecimal conversion we start dividing the decimal number by 16 and

Number System CScXI/2013_2014/MK_MD/13 #3

Delhi Public School, R.K.Puram Computer Science repeat the process with the quotient of the division, till you get a quotient which cannot be further divided by 16 and then collect the remainders of all the divisions in the reverse order. Note that, for such divisions if ever a remainder is more than 9 then the remainder has to be represented as A, B, C...(till F)

Example: Decimal to Hexadecimal Base Quotient Remainder

16 123 11 (B)

7 So, the number equivalent to decimal number 123 will be 7B in Hexadecimal.

Internal Storage encoding of Characters: Characters are converted into their equivalent binary form using certain standard codes as follows:

ASCII - American Standard Code for Information Interchange - The American Standard Code for Information Interchange (ASCII, pronunciation: /Aæski/ ass-kee) is a character-encoding scheme originally based on the English alphabet. ASCII codes represent text in computers, communications equipment, and other devices that use text. Most modern character-encoding schemes are based on ASCII, though they support many additional characters.

ISCII -Indian scripts Standard Code for Information Interchange - It is a coding scheme for representing various writing systems of India. It encodes the main Indic scripts and a Roman transliteration. The supported scripts are: Assamese, Bengali (Bangla), Devanagari, Gujarati, , Kannada, Malayalam, Oriya, Tamil, and Telugu. ISCII does not encode the writing systems of India based on , but its writing system switching codes nonetheless provide for Kashmiri, Sindhi, Urdu, Persian, Pashto and Arabic. The Arabic-based writing systems were subsequently encoded in the PASCII encoding.

UNICODE - (for multilingual ) - Unicode is a computing industry standard for the consistent encoding, representation and handling of text expressed in most of the world's writing systems. Developed in conjunction with the Universal Character Set standard and published in book form as The Unicode Standard, the latest version of Unicode contains a repertoire of more than 110,000 characters covering 100 scripts.

Number System CScXI/2013_2014/MK_MD/13 #4