Skip to content

Instantly share code, notes, and snippets.

@KentaYamada
Created November 5, 2016 04:39
Show Gist options
  • Select an option

  • Save KentaYamada/2ce240f105cea37b815f2753119649e4 to your computer and use it in GitHub Desktop.

Select an option

Save KentaYamada/2ce240f105cea37b815f2753119649e4 to your computer and use it in GitHub Desktop.
バイトデータからビットデータ取り出し
#include <iostream>
int main()
{
char c = 0x05; //Binary: 00000101
for(int i = 0; i <= 2; i++) {
std::cout << (unsigned int)((c >> i) & 0x01) << std::endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment