11
If we have a number n 4 n 3 n 2 n 1 n -1 n -2 n -3 and base or radix is b so the value of the number is n 3 *b 3 + n 2 *b 2 + n 1 *b 1 + n 0 *b 0 + n -1 *b -1 + n -2 *b -2 So we can vary the value of b to get a different number system. We specify the value of the base as suffix to the number to represent which number system is being used. There are following number systems which are generally used to represent a value. 1. Decimal system: This is the system which we use in daily life Value of b=10 e.g. (456) 10 = 4*10 2 + 5*10 1 + 6* 10 0 The weights of the corresponding bits for decimal system are as 10 4 10 3 10 2 10 1 10 0 . 10 -1 10 - 2 1000 0 100 0 10 0 10 1 . 0.1 0 0.0 1 MSB Decimal point 1. Binary system: This is number system which is used to represent values in the digital environment. Here value of b=2 (11101.01) 2 =1*2 4 + 1 *2 3 + 1 * 2 2 + 0 *2 1 + 1 * 2 0 + 0 *2 -1 + 1 * 2 -2 = (29.25) 10 so number given is equal to 29 in decimal.

Number System

Embed Size (px)

Citation preview

Page 1: Number System

If we have a number    n4n3 n2 n1 n-1 n-2 n-3   and base or radix is b so the value of the number is

n3*b3   + n2 *b2+ n1 *b1+ n0 *b0 + n-1 *b-1+ n-2 *b-2

So we can vary the value of b to get a different number system. We specify the value of the base as suffix to the number to represent which number system is being used. There are following number systems which are generally used to represent a value.

 

1. Decimal system: This is the system which we use in daily life

Value of b=10

e.g.  (456)10

= 4*102 + 5*101 + 6* 100

The weights of the corresponding bits for decimal system are as

 104 103 102 101 100 . 10-1 10-2

10000 1000 100 10 1 . 0.10 0.01MSB         Decimal 

point   

 

1. Binary system: This is number system which is used to represent values in the digital environment. Here value of b=2

(11101.01)2

=1*24 + 1 *23 + 1 * 22 + 0 *21 + 1 * 20+ 0 *2-1 + 1 * 2-2

= (29.25)10 so number given is equal to 29 in decimal. 

Representing large values in binary system may be very cumbersome and also it’s very difficult to a human to work with such large values in binary as it require 3 to 4 time more digits than for decimal system for same value e.g. 10101111011101112.Hence the number systems like octal and hexadecimal systems are developed just to simplify this. Corresponding equivalents of the value above in octal and hexadecimal are 1275678 and AF7716  that are easier to read and remember for engineers and other technicians

 

The weights of the corresponding bits for binary system are as 24 23 22 21 20 . 2-1 2-2

16 8 4 2 1 . 0.50 0.25

Page 2: Number System

MSB         Decimal point

   

 

However, any series of 1’s and 0’s is not binary number. Sometimes it may represent some other information like some binary codes as gray code, parity bit numbers etc

 Binary number formats:

1. Bit: It is defined as smallest unit of data. Eg. 0, 12. Nibble: It is a combination of 4 bits Eg. 0000, 1010, 1000, 0100 etc3. Byte: A byte is a combination of 8 bits Eg. 0010 1010—it has 2 nibbles4. Word: it is defined as combination of 16 bits Eg. 0010 0011 0111 1111 – it

has 4 nibbles or 2 bytes5. Double word: It is defined as combination of 32 bits.Eg. 0010 0011 0111

1111 0010 0011 0111 1111 it has 8 nibbles or 4 bytes

6. Octal system: b=87. (407)88. = 4 * 82 + 0 *81 + 7 * 80

9. = (261)1010. Similarly 24.68 = 2 x (81) + 4 x (80) + 6 x (8-1) = 20.7510

11. 11.18 = 1 x (81) + 1 x (80) + 1 x (8-1) = 9.12510

12.  13. The weights of the corresponding bits for octal system are as

84 83 82 81 80 . 8-1 8-2

4096 512

64 8 1 . 0.125 0.015625

MSB         Decimal point

   

14.  15. 2. Hexadecimal system: b=16                          {value of A=10, B=11, C=12, D=13, E=14, 

F=15}16. (A0F) 1617. = A * 162 + 0 *161 + F *160

18. = 10 * 162 + 0 *161 + 15 *160

19. =2560 + 1520. = (2575) 1021. Similarly 11.116 = 1 x (161) + 1 x (160) + 1 x (16-1) = 17.062510

22.  12.316 = 1 x (161) + 2 x (160) + 3 x (16-1) = 18.187510

23.  24. The weights of the corresponding bits for hexadecimal system are as25.  

164 163 162 161 160 . 16-1 16-2

65536 4096 256 16 1 . 0.125 0.015625MSB         Decimal 

point   

Page 3: Number System

26.                27.  28.  29. Corresponding equivalents of decimal 0-15 in Binary, octal & hexadecimal system30.  31. Decimal                                Binary                   Octal                      Hexadecimal     32.  0                             0000                      00                           033.  1                              0001                      01                           1           34.  2                             0010                      02                           2    35.  3                             0011                      03                           3 36.  4                             0100                      04                           4             37.  5                             0101                      05                           5     38.  6                             0110                      06                           6        39.  7                             0111                      07                           7                       40.  8                             1000                      10                           8             41.  9              1001                      11                           9                42. 10                           1010                      12                           A                      43. 11                           1011                      13                           B 44. 12                           1100                      14                           C                                  45. 13                            1101                      15                           D                         46. 14                            1110                      16                           E               

15              15               1111                      17                           F    Decimal to binary:

Successive division method for integral values: Let the decimal number be 26 so we can convert it to binary by dividing the number  with the base=2  and then write the quotient and remainder as shown below and then again divide the quotient with the base till we get quotient as zero. This method is also called Double-dabblemethod.

Successive multiplication method for fractional values: Conversion of fraction from decimal to binary follows the following procedure: just multiply the fraction by base and integer which we get to left of the decimal point is saved

Fraction is 0.3875

0.3875 * 2                            =0.7750                =0 + 0.7750         a-1=0

0.7750 * 2                            =1.5500                =1 + 0.5500         a-2=1

0.5500 * 2                            =1.1000                =1 + 0.1000         a-3=1

Page 4: Number System

0.1000 * 2                            =0.2000                =0 + 0.2000         a-4=0

And the procedure may go on till we get the fractional part as zero but this may not be possible in finite no of bits hence usually we restrict the no of bits to represent the value to a finite value and get an approximate value…

So the (0.3875)10 = 0.a-1 a-2 a-3 a-4 ……= (0.0110….) 2 = (0.0110)2

If we convert the value (0.0110)2 back to decimal

=0 * 2-1 + 1 * 2-2 + 1 * 2-3 + 0*2-4 =0 * 0.5 + 1 * 0.25 + 1 * 0.125 + 0*.0625 =0.3750 which is only approximate value of the actual value. So we see the equivalent we get in binary for a fraction may only be an approximate value.  We may increase the no of bits to increase the accuracy. So the precision we get depends on the no. of bits we have chosen to represent the number. Sometimes we may get the accurate equivalent in small no of bits.

Q- Convert decimal 13.75 into binary equivalent.

Ans: We first divide the integer and the fraction part and then convert them separately into binary equivalents and then again append them with a decimal point between them as shown below:

Binary equivalent of 13 we get, with the procedure mentioned above, is 1101

And to get the binary equivalent of 0.75

0.75 * 2                                =1.50                     = 1 + 0.50             a-1=1

0.50 * 2                                 =1.00                     =1+0.00                a-2=1

So we get the binary equivalent as 0.11. In this case as we have the fractional part as Zero and hence 0.11 is the exact equivalent of 0.75

Now we append the two values and get the binary equivalent of 13.75 as (1101.11) 2

 

Decimal to Octal:

Let the decimal number be 26 so we can convert it to octal by dividing the number with the base=8  and then write the quotient and remainder as shown below and then again divide the quotient with the base till we get quotient as zero. This method is also called Oct-dabble method.

Page 5: Number System

Conversion of fraction from decimal to octal is similar to the one for binary and follows the following procedure: just multiply the fraction by base=8 and integer which we get to left of the decimal point is saved

Fraction is 0.3875

0.3875 * 8                            =3.1000                =3 + 0.1000         a-1=3

0.1000 * 8                            =0.8000                =0 + 0.8000         a-2=0

0.8000 * 8                            =6.4000                =6 + 0.4000         a-3=6

0.4000 * 8                            =3.2000                =3 + 0.2000         a-4=3

And let me re-write the same facts about the procedure followed above. It may go on till we get the fractional part as zero but this may not be possible in finite no of bits hence usually we restrict the no of bits to represent the value to a finite value and get an approximate value…

So the (0.3875)10 = 0.a-1 a-2 a-3 a-4 ……= (0.3063….) 8 = (0.3063)8

If we convert the value (0.3063)2 back to decimal

=3 * 8-1 + 0 * 8-2 + 6 * 8-3 + 3 *8-4 =0.3777 which is only approximate value of the actual value. So we see the equivalent we get in nay number system for a fraction may only be an approximate value. The same again that we may increase the no of bits to increase the accuracy.

Decimal to Hexadecimal: following the same procedure

Convert 26 decimal to hexadecimal: This method is also called Hex-dabblemethod.

 Convert 0.3875 to hexadecimal

We can convert a fraction from a decimal to hexadecimal form by multiplying wit base and following the same procedure.

Fraction is 0.3875

0.3875 * 16                          =6.2000                =6 + 0.2000         a-1=6

0.2000 * 16                          =3.2000                =3 + 0.2000         a-2=3

0.2000 * 16                          =3.2000                =3 + 0.2000         a-3=3

Similarly a-4=3, a-5=3, a-6=3 so on…….

Page 6: Number System

Hence the hexadecimal equivalent is 0.63333…

 

 Binary to octal and hexadecimal:

To convert the number from binary to octal we make groups of 3 bits starting from the decimal point (in case of fractions)  and from right most bit (in case of integers) and write the corresponding octal equivalent of those 3 bits every time.

The process of replacing the long strings of 1 & o with the shorter strings like Octal & hexadecimal equivalents is known as chunking.

Hexadecimal and octal to binary:

To do the above we convert the digits into their corresponding binary equivalents of 3-bits and 4-bits for octal and hexadecimal numbers respectively.

Page 7: Number System

ADDITION

Decimal system: Although all of us are doing addition in decimal system since years and this may look a bit odd to study this again but I’ll still emphasize to study it further. Let us analyze the addition for decimal system.  For addition we firstly add least significant digits and keep the least significant digit of the result we get, in the least significant position of the sum and rest of the part is taken as carry and added to the next digits as:

But let me put it in another way which is actually a generalized method for addition. We first add least significant digits and if result we get is equal to or more that ‘10’ (base) then we’ll subtract ‘10’ (b) from the result as many times we can and remainder is then saved in the sum register while the number of times we can subtract is taken as carry.

Now we’ll take this method and apply it to any system for addition

Page 8: Number System

Binary system:

There are 4 cases of addition of bit by bit:

                Sum       carry

0 + 0 =     0                0

1 + 0 =      1               0

0 + 1 =      1               0

1 + 1 =      1             1

Page 9: Number System