title: Finding out if a number in a cell is even or odd
body: <p>Given that a number in the 0th cell of tape is filled and the rest are all just used as scratch cells (i.e. they all start at 0 and are temporaries -- I don't care what happens to them), I would like to replace the 0th cell with a 0 or a 1. 0 if even, 1 if odd.</p>
  
  <p>Basically, what I want to do is (in C-esque pseudocode):</p>
  
  <pre><code>cell[0] = (cell[0] % 2)
  </code></pre>
  
  <p>I know that there exists a <a href="http://esolangs.org/wiki/Brainfuck_algorithms#Divmod_algorithm" rel="nofollow">divmod algorithm</a> defined as follows:</p>
  
  <blockquote>
    <p>If one does not need to preserve n, use this variant: </p>
  
  <pre><code># &gt;n d
  [-&gt;-[&gt;+&gt;&gt;]&gt;[+[-&lt;+&gt;]&gt;+&gt;&gt;]&lt;&lt;&lt;&lt;&lt;]
  # &gt;0 d-n%d n%d n/d
  </code></pre>
  </blockquote>
  
  <p>However, since <code>X % 2 == X &amp; 1</code>, i.e. X mod 2 is the rightmost bit of X, I think that divmod might be overkill in terms of complexity of calculation.</p>
  
  <p>Is there any better algorithm/technique for finding out if the cell is even or not?</p>