title: C++ - Aligning memory
body: <p>I really want to understand what is happening on these two lines</p>
  
  <pre><code>const int PAGES = 8 * 1024;
  
  // PAGES + extra 4KiB for alignment
  uint8_t * mem = new uint8_t [ PAGES * CCPU::PAGE_SIZE + CCPU::PAGE_SIZE ];
  
  // align to a mutiple of 4KiB
  uint8_t * memAligned = (uint8_t *) (( ((uintptr_t) mem) + CCPU::PAGE_SIZE - 1) &amp; ~(uintptr_t) ~CCPU::ADDR_MASK );
  </code></pre>
  
  <p>especially the last line, I don't understand to anything...</p>