Created
September 5, 2018 07:49
-
-
Save ladislas/551a2c2b56bbe774a7d5cdd550b3472a to your computer and use it in GitHub Desktop.
Simple bit manipulation
This file contains hidden or 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
#include <iostream> | |
#include <bitset> | |
// g++ main.cpp -o main && ./main | |
uint8_t b = 0b00000001; | |
int main() { | |
b |= (1 << 7); | |
if (b & 0x06) { | |
std::bitset<8> x(b); | |
std::cout << "hello " << x << " world" << std::endl; | |
} | |
else { | |
std::cout << "niam..." << std::endl; | |
} | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment