title: How does this statement test for memory alignment
body: <p>I am writing a hobby OS, using several guides. Page aligning memory is a recurring theme. Several guides test if a certain address is page aligned by using the following statement:</p>
  
  <pre><code>if (address &amp; 0xFFFFF000) // if true the address is not page aligned
  </code></pre>
  
  <p>I don't get how that tests for page alignment. If I take a non-paged aligned (4k pages) address, f.e. <code>0x12345678</code> and <code>AND</code> that with <code>0xFFFFF000</code> on my calculator I get <code>0x12345000</code>. That is non-zero so the <code>if</code>-statement is <code>true</code>.</p>
  
  <p>However, if i take an aligned address, f.e. <code>0x12345000</code> and perform the same calculation I (obviously) get <code>0x12345000</code> as well.</p>
  
  <p>So how is this statement testing for page-alignment?</p>
  
  <p>Edit:</p>
  
  <p>For example this guide uses this test at several points: <a href="http://www.jamesmolloy.co.uk/tutorial_html/1.-Environment%20setup.html" rel="nofollow">http://www.jamesmolloy.co.uk/tutorial_html/1.-Environment%20setup.html</a></p>