Skip to content

Instantly share code, notes, and snippets.

@alexandercerutti
Last active December 29, 2021 14:42
Show Gist options
  • Save alexandercerutti/b38dfc2e0a4b00597cee567bcb0ee53d to your computer and use it in GitHub Desktop.
Save alexandercerutti/b38dfc2e0a4b00597cee567bcb0ee53d 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 /***/ = 0b0000, /* Set to 0 because it is the initial state */
FAILED /****/ = 0b0001,
LOADED /****/ = 0b1110,
PLAYING /***/ = 0b0100,
STOPPED /***/ = 0b1000
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment