Skip to content

Instantly share code, notes, and snippets.

@StefanoFiumara
Created November 16, 2013 04:12
Show Gist options
  • Save StefanoFiumara/7495847 to your computer and use it in GitHub Desktop.
Save StefanoFiumara/7495847 to your computer and use it in GitHub Desktop.
int VirtualMemoryManager::get_mask(int last_x_bits) {
int mask = 0;
for(int i = 0; i < last_x_bits; i++) {
mask += pow(2, i);
}
return mask;
}
@zmughal
Copy link

zmughal commented Nov 18, 2013

Just do mask = (1 << last_x_bits) - 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment