The Numeric Systems:
Conversion from Decimal to Binary

 

Converting a Byte From Decimal to Binary

Remember that the maximum decimal number you can store in a byte is 255. Once you have a decimal number, you can use the remainder operation to fill out the bits. Let's convert the number 206.

Considering 206, since this is greater than 128, fill out bit 7 with 1. This produces:

128 64 32 16 8 4 2 1
1              
 

Next, find the remainder of 206 by 128:

As you can see, the remainder of dividing 206 by 128 is 78. Therefore, fill out the corresponding bit of 64, which is bit 6, with 1:

128 64 32 16 8 4 2 1
1 1            
 

Next, find the remainder of 78 by 64. This produces 14. 14 is less than 32. Therefore, the bit corresponding to decimal 32, which is bit 5, has a binary value of 0. 14 is less than 16. Therefore, bit 4 is 0. 14 is greater than 8. Therefore, fill out bit 3 with 1:

128 64 32 16 8 4 2 1
1 1 0 0 1      

Now, find the remainder of  14 by 8. This is 6. 6 is greater than 4. Therefore, bit 2 has a binary value of 1.

128 64 32 16 8 4 2 1
1 1 0 0 1 1    

Find the remainder of 6 by 4. This is 2. According to this, bit 1 will have a binary value of 1. The remaining decimal value is 0. Therefore, bit 0 has a value of 0. The decimal number 206 produces the following table:

  128 64 32 16 8 4 2 1
  1 1 0 0 1 1 1 0
 
= 1 1 0 0 1 1 1 0
    = 11001110
    = 1100 1110
 

Practical Learning Practical Learning: Converting a Byte From Decimal to Binary

  1. On the Calculator, click the Dec radio button and click the buttons to enter 206
  2. Click the Bin radio button to see the result
 

Converting any Number From Decimal to Binary

Converting a decimal number to binary takes longer because of the various comparisons you would perform. There are, as always, various techniques available. Once again, find the range of the number using numbers such as those:

2n-1 230 229 228 227 226 225 224
etc 1,073,741,824 536,870,912 268,435,456 134,217,728 67,108,864 33,554,432 16,777,216
 
223 222 221 220 219 218 217 216
8,388,608 4,194,304 2,097,152 1,048,576 524,288 262,144 131,072 65,536
 
215 214 213 212 211 210 29 28
32,768 16,384 8,192 4,096 2,048 1,024 512 256
 
27 26 25 24 23 22 21 20
128 64 32 16 8 4 2 1

Imagine you would like to convert the following decimal number 408340623 = 408,340,623 to binary (I picked this number completely randomly).

408,340,623 is less than 536,870,912 but is greater than 268,435,456. Therefore, we will start the counting at 268,435,456. Write 1 under 268,435,456.

    536,870,912 268,435,456 134,217,728 67,108,864 33,554,432 16,777,216
    0 1        

At this time, we have the number as 1.

Next, find the remainder (you can use a calculator) of 408,340,623 by 268,435,456, which is 139,905,167. 139,905,167 is greater than 134,217,728. Therefore, write 1 under 134,217,728

    536,870,912 268,435,456 134,217,728 67,108,864 33,554,432 16,777,216
    0 1 1      

The current number is 11000 or 1 1000

Now, find the remainder of 139,905,167 by 134,217,728. This is 5,687,439. This number is between 8,388,608 and 4,194,304. Therefore, fill each bit to 0 down to 4,194,304:

    536,870,912 268,435,456 134,217,728 67,108,864 33,554,432 16,777,216
    0 1 1 0 0 0
 
8,388,608 4,194,304 2,097,152 1,048,576 524,288 262,144 131,072 65,536
0              

Since 4,194,304 is immediately less than 5,687,439 fill it with 1

    536,870,912 268,435,456 134,217,728 67,108,864 33,554,432 16,777,216
    0 1 1 0 0 0
 
8,388,608 4,194,304 2,097,152 1,048,576 524,288 262,144 131,072 65,536
0 1            

The number becomes 1100001 or 110 0001.

Then find the remainder of 5,687,439 by 4,194,304. This produces 1,493,135. This number is greater than 1,048,576. Therefore, write 0 under 2,097,152 and 1 under 1,048,576.

    536,870,912 268,435,456 134,217,728 67,108,864 33,554,432 16,777,216
    0 1 1 0 0 0
 
8,388,608 4,194,304 2,097,152 1,048,576 524,288 262,144 131,072 65,536
0 1 0 1        

Now the number is 110000101 or 1 1000 0101

Find the remainder of 1,493,135 by 1,048,576. The result is 444,559. The next number greater than 444,559 is 262,144. Therefore, fill it with 1 and fill out the 524,288 field with 0:

    536,870,912 268,435,456 134,217,728 67,108,864 33,554,432 16,777,216
    0 1 1 0 0 0
 
8,388,608 4,194,304 2,097,152 1,048,576 524,288 262,144 131,072 65,536
0 1 0 1 0 1    

The number has become 11000010101 or 110 0001 0101

Find the remainder of 444,559 by 262,144. This is 182415. This number is greater than 131,072. Therefore, fill out the corresponding bit with 1.

    536,870,912 268,435,456 134,217,728 67,108,864 33,554,432 16,777,216
    0 1 1 0 0 0
 
8,388,608 4,194,304 2,097,152 1,048,576 524,288 262,144 131,072 65,536
0 1 0 1 0 1 1  

The current number is 110000101011 or 1100 0010 1011

The remainder of 182,415 by 131,072 is 51,343 which is less than 65,536 but greater than 32,768. For this reason, the equivalent bit of 65,536 is 0 and that of 32,768 is 1:

    536,870,912 268,435,456 134,217,728 67,108,864 33,554,432 16,777,216
    0 1 1 0 0 0
 
8,388,608 4,194,304 2,097,152 1,048,576 524,288 262,144 131,072 65,536
0 1 0 1 0 1 1 0
 
32,768 16,384 8,192 4,096 2,048 1,024 512 256
1              

The current number is 11000010101101 or 11 0000 1010 1101

The remainder of 51,343 by 32,768 is 18,575. This number is between 32,768 to 16,384. This results in:

    536,870,912 268,435,456 134,217,728 67,108,864 33,554,432 16,777,216
    0 1 1 0 0 0
 
8,388,608 4,194,304 2,097,152 1,048,576 524,288 262,144 131,072 65,536
0 1 0 1 0 1 1 0
 
32,768 16,384 8,192 4,096 2,048 1,024 512 256
1 1            

The number becomes 110000101011011 or 110 0001 0101 1011

The remainder of 18,575 by 16,384 is 2191. This number is greater that 2048. Therefore, the binary equivalents of both the 8,192 and the 4,096 bits is 0. The bit equivalent of 2,048 is 1:

    536,870,912 268,435,456 134,217,728 67,108,864 33,554,432 16,777,216
    0 1 1 0 0 0
 
8,388,608 4,194,304 2,097,152 1,048,576 524,288 262,144 131,072 65,536
0 1 0 1 0 1 1 0
 
32,768 16,384 8,192 4,096 2,048 1,024 512 256
1 1 0 0 1      

The number becomes 110000101011011001 or 11 0000 1010 1101 1001

The remainder of 2,191 by 2,048 is 143. The next number lower than 143 is 128. The resulting tables are:

    536,870,912 268,435,456 134,217,728 67,108,864 33,554,432 16,777,216
    0 1 1 0 0 0
 
8,388,608 4,194,304 2,097,152 1,048,576 524,288 262,144 131,072 65,536
0 1 0 1 0 1 1 0
 
32,768 16,384 8,192 4,096 2,048 1,024 512 256
1 1 0 0 1 0 0 0
 
128 64 32 16 8 4 2 1
1              

The current number is 1100001010110110010001 or 11 0000 1010 1101 1001 0001

Find the remainder of 143 by 128. This produces 15; a number that is greater than 8 but less than 16. The bits of 64, 32, and 16 will receive a bit value of 0. Bit 8 will have a value of 1:

    536,870,912 268,435,456 134,217,728 67,108,864 33,554,432 16,777,216
    0 1 1 0 0 0
 
8,388,608 4,194,304 2,097,152 1,048,576 524,288 262,144 131,072 65,536
0 1 0 1 0 1 1 0
 
32,768 16,384 8,192 4,096 2,048 1,024 512 256
1 1 0 0 1 0 0 0
 
128 64 32 16 8 4 2 1
1 0 0 0 1      

The current number is:

11000010101101100100010001 or 11 0000 1010 1101 1001 0001 0001

The remainder of 15 by 8 is 7, which is greater than 4. Fill out bit 2 with 1.

    536,870,912 268,435,456 134,217,728 67,108,864 33,554,432 16,777,216
    0 1 1 0 0 0
 
8,388,608 4,194,304 2,097,152 1,048,576 524,288 262,144 131,072 65,536
0 1 0 1 0 1 1 0
 
32,768 16,384 8,192 4,096 2,048 1,024 512 256
1 1 0 0 1 0 0 0
 
128 64 32 16 8 4 2 1
1 0 0 0 1 1    

The current number is:

110000101011011001000100011 or 110 0001 0101 1011 0010 0010 0011

The remainder of 7 by 4 is 3, which is greater than 2. This produces:

    536,870,912 268,435,456 134,217,728 67,108,864 33,554,432 16,777,216
    0 1 1 0 0 0
 
8,388,608 4,194,304 2,097,152 1,048,576 524,288 262,144 131,072 65,536
0 1 0 1 0 1 1 0
 
32,768 16,384 8,192 4,096 2,048 1,024 512 256
1 1 0 0 1 0 0 0
 
128 64 32 16 8 4 2 1
1 0 0 0 1 1 1  

The current number is:
1100001010110110010001000111 or 1100 0010 1011 0110 0100 0100 0111

The remainder of 3 by 2 is 1. This means that you will fill out bit 0 with 1:

    536,870,912 268,435,456 134,217,728 67,108,864 33,554,432 16,777,216
    0 1 1 0 0 0
 
8,388,608 4,194,304 2,097,152 1,048,576 524,288 262,144 131,072 65,536
0 1 0 1 0 1 1 0
 
32,768 16,384 8,192 4,096 2,048 1,024 512 256
1 1 0 0 1 0 0 0
 
128 64 32 16 8 4 2 1
1 0 0 0 1 1 1 1

The final number is:
11000010101101100100010001111 or 1 1000 0101 0110 1100 1000 1000 1111

The equivalent decimal number of 408340623 in binary is 11000010101101100100010001111 or 1 1000 0101 0110 1100 1000 1000 1111

 

Practical Learning Practical Learning: Converting a Number From Decimal to Binary

  1. On the Calculator, click the Dec radio button and click the buttons to enter 408340623
     
  2. Click the Bin radio button to see the result
     
 

Previous Copyright © 2003-2009, FunctionX Next