mirror of
https://github.com/VictorEijkhout/TheArtOfHPC_vol3_cppf08programming.git
synced 2026-01-24 22:44:48 +09:00
29 lines
692 B
C++
29 lines
692 B
C++
/****************************************************************
|
|
****
|
|
**** This file belongs with the course
|
|
**** Introduction to Scientific Programming in C++/Fortran2003
|
|
**** copyright 2023 Victor Eijkhout eijkhout@tacc.utexas.edu
|
|
****
|
|
**** bitset.cxx : bitwise operators
|
|
****
|
|
****************************************************************/
|
|
|
|
#include <iostream>
|
|
using std::cin, std::cout;
|
|
#include <bitset>
|
|
using std::bitset;
|
|
|
|
int main() {
|
|
|
|
//codesnippet bitsetandor
|
|
bitset<8> xb(6);
|
|
bitset<8> yb(3);
|
|
auto xory = (xb|yb).to_ulong();
|
|
cout << "6|3 = " << (xb|yb) << " = "
|
|
<< xory << '\n';
|
|
cout << "6&3 = " << (xb&yb) << '\n';
|
|
//codesnippet end
|
|
|
|
return 0;
|
|
}
|