Skip to content

Instantly share code, notes, and snippets.

@killwing
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save killwing/0b0fa26babc928f42c2a to your computer and use it in GitHub Desktop.
Save killwing/0b0fa26babc928f42c2a to your computer and use it in GitHub Desktop.
useful bit hacks
// round down to multiple of 1024
size_t roundDown(size_t s) {
return s & ~1023;
}
// round up to multiple of 1024
size_t roundUp(size_t s) {
return (s + 1023) & ~1023;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment