title: Bitwise Operator & Logic
body: <p>I need clarification on a problem that I have. I am currently trying to learn Perl using the Beginning Perl book provided by the "Learn Perl" portion of the Perl website. I am down to the ending of chapter 2 and I am currently having a hard time trying to understand the logic behind a solution that the book provided.</p>
  
  <pre><code>#!usr/bin/perl
  #Ex2_3.plx
  use warnings;
  
  
  print "Please enter the value(less than 256) you wish to be converted into binary\n";
  my $bin = &lt;STDIN&gt;;
  chomp ($bin);
  
  print "The binary value of $bin is : ", "\n";
  
  #Use the bitwise and operator to determine the binary value:
  
  
  print((128 &amp; $bin) / 128);
  print((64 &amp; $bin) / 64);
  print((32 &amp; $bin) / 32);
  print((16 &amp; $bin) / 16);
  print((8 &amp; $bin) / 8);
  print((4 &amp; $bin) / 4);
  print((2 &amp; $bin) / 2);
  print((1 &amp; $bin) / 1);
  print("\n");
  </code></pre>
  
  <p>I can't seem to understand the logic behind (128 &amp; n) / 128 and so forth.
  While I do understand why is it that the code needs to go from 128 down to 1 I can't seem to grasp the solution after &amp;. I feel bad because I normally hate looking at solutions, but this  is all very intriguing to me, most other programming books put very small(if any) attention to bitwise operators.
  I will appreciate the help.</p>