Skip to content

Instantly share code, notes, and snippets.

@alexandercerutti
Last active December 29, 2021 14:42
Show Gist options
  • Save alexandercerutti/d25ee6626fe64fa2cc5a613052ca308d to your computer and use it in GitHub Desktop.
Save alexandercerutti/d25ee6626fe64fa2cc5a613052ca308d to your computer and use it in GitHub Desktop.
bitwise-article
/**
* In grid reading, it is important to have all the bits aligned.
* Unaligned bits can lead to misreading and therefore to bugs.
*
* Trust me, I've shipped in production a product that had a
* broken feature due to a wrong bit.
*/
enum States {
LOADING /***/ = 0b000000, /* Set to 0 because it is the initial state */
FAILED /****/ = 0b000001,
LOADED /****/ = 0b000010,
PLAYING /***/ = 0b000100,
STOPPED /***/ = 0b001000
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment