avatar7's tags:
avatar7 reads (1):
Who's reading avatar7 (2):
There are many methods to convert decimal number into the corresponding binary. Only one famous method will be discussed here: Converting decimal to binary: The rules are as follows: *You should start from the left most binary digit *If the decimal number is equal or greater than the place value (corresponding 2^number), then place the bit 1 and forward the difference to the next digit on the right *If the decimal number is less than the place value , then place the bit 0 and forward the number as it is to the next digit on the right Example: Suppose you got the decimal number 170: - 170 is greater than 128(27) , so the left most bit is 1 , get the difference 170-128=42 -forward 42 to the next digit -42 is less than 64( 26), so place 0 and forward the number as it is (42) to the next step -42 is greater than 32(25), so place 1 and forward the difference which is 42-32=10 -10 is less than 16(24), so place 0 and forward the 10 as it is -10 is greater than 8(23) so place 1 and forward the difference which is 10-8=2 -2 is less than 4( 22) so place 0 and forward the 2 as it is -2 is equal 2( 21) so place a 1 and forward the difference which is 2-2=0 -0 is less than 1(20) so place a zero and you're done so the decimal number 170 is equal to the binary number 10101010 NOTE THE FOLLOWING: *The right most place value is 20 *Whenever you get a zero difference, all the next digits will be o's as zero will be less than 2^whichever number *Only numbers from 0-255 can be represented by 8 digits binary .Numbers greater than 255 will be represented by more bits. For example: 256 is represented by 9 digits: 100000000. In general 2^n -1 gives you the largest number that can be represented by n digits. So in 8 digits binary, max. number is 2^8 -1= 255. In 9 digits binary, max.number is 2^9-1=511. So the range for 9 digits is from 256-511. Starting from 512 ,10 digits will be required.And so on............ Coverting binary to decimal: An example about this was already shown in the previous 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 example shows that the binary number 00010110 is equal to the decimal number 22. In general , all the 0 bits will add up to zero , so just ignore them and add the 1's. Here is another example: 10101010= (1*27=128) + (1*25 =32) + (1*23 = 8) + (1* 21 = 2) = 170 ( we've already seen that 170 is = 10101010).

del.icio.us Digg reddit StumbleUpon

Comment on "Coverting decimal to 8-bits binary and vice versa"

Cisco networks IT networking CCNA (Click to add tags below)

(Separate tags using commas, for example: New York, dating, vegetarian)
Comment Anonymously