Wednesday, December 3, 2008

Coverting Decimal To 8 Bits Binary And Vice Versa

There are some methods to modify quantitative sort into the same binary. Only member famous method module be discussed here:

Converting quantitative to binary:

The rules are as follows:

*You should move from the mitt most star digit

*If the quantitative sort is coequal or greater than the locate continuance (corresponding 2number), then locate the taste 1 and nervy the disagreement to the incoming member on the right

*If the quantitative sort is inferior than the locate continuance , then locate the taste 0 and nervy the sort as it is to the incoming member on the right

Example:

Suppose you got the quantitative sort 170:

- 170 is greater than 128(27) , so the mitt most taste is 1 , intend the disagreement 170-128=42

-forward 42 to the incoming digit

-42 is inferior than 64( 26), so locate 0 and nervy the sort as it is (42) to the incoming step

-42 is greater than 32(25), so locate 1 and nervy the disagreement which is 42-32=10

-10 is inferior than 16(24), so locate 0 and nervy the 10 as it is

-10 is greater than 8(23) so locate 1 and nervy the disagreement which is 10-8=2

-2 is inferior than 4( 22) so locate 0 and nervy the 2 as it is

-2 is coequal 2( 21) so locate a 1 and nervy the disagreement which is 2-2=0

-0 is inferior than 1(20) so locate a set and you're done

so the quantitative sort 170 is coequal to the star sort 10101010

NOTE THE FOLLOWING:

*The correct most locate continuance is 20

*Whenever you intend a set difference, every the incoming digits module be o's as set module be inferior than 2whichever number

*Only drawing from 0-255 crapper be represented by 8 digits star .Numbers greater than 255 module be represented by more bits. For example: 256 is represented by 9 digits: 100000000. In generalized 2n -1 gives you the maximal sort that crapper be represented by n digits. So in 8 digits binary, max. sort is 28 -1= 255. In 9 digits binary, max.number is 29-1=511. So the arrange for 9 digits is from 256-511. Starting from 512 ,10 digits module be required.And so on............

Converting star to decimal:

An warning most this was already shown in the preceding post.

00010110 = (1 x 24 = 16) + (0 x 23 = 0) + (1 x 22 = 4) + (1 x 21 = 2) + (0 x 20 = 0) = 22 (16 + 0 + 4 + 2 + 0)

This warning shows that the star sort 00010110 is coequal to the quantitative sort 22.

In generalized , every the 0 bits module add up to set , so meet cut them and add the 1's. Here is added example:

10101010= (1*27=128) + (1*25 =32) + (1*23 = 8) + (1* 21 = 2) = 170

( we've already seen that 170 is = 10101010).

Cisco website

Cisco Academy Program

Source: http://cisconetworkingbasics.blogspot.com