title: Aligning virtual address to immediate next page boundary
body: <p>I came across following algorithm that aligns virtual address to immediate next page bounday.</p>
  
  <pre><code>VirtualAddr = (VirtualAddr &amp; ~(PageSize-1));
  </code></pre>
  
  <p>Also, given a length of bytes aligns length (rounds it) to be on the page boundary</p>
  
  <pre><code>len = ((PageSize-1)&amp;len) ? ((len+PageSize) &amp; ~(PageSize-1)):len;
  </code></pre>
  
  <p>I am finding it hard to decipher how this works.
  Can someone help me out to break it down?</p>