Skip to content

Instantly share code, notes, and snippets.

@ladislas
Created September 5, 2018 07:49
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 ladislas/551a2c2b56bbe774a7d5cdd550b3472a to your computer and use it in GitHub Desktop.
Save ladislas/551a2c2b56bbe774a7d5cdd550b3472a to your computer and use it in GitHub Desktop.
Simple bit manipulation
#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