Created
September 30, 2021 07:52
-
-
Save Wendelstein7/f9684cd7b0c57e030b267e5ade30928c to your computer and use it in GitHub Desktop.
Bitwise operation macros (Compatible with C, C++, C#, etc...)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define isBitSet(byte, bit) ((byte) & (1 << (bit))) | |
#define setBit(byte, bit) ((byte) |= (1 << (bit))) | |
#define clearBit(byte, bit) ((byte) &= ~(1 << (bit))) | |
#define toggleBit(byte, bit) ((byte) ^= (1 << (bit))) | |
#define setBitTo(byte, bit, value) ((value) ? setBit(byte, bit) : clearBit(byte, bit)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment