Last active
August 29, 2015 13:56
-
-
Save yysaki/9308510 to your computer and use it in GitHub Desktop.
bbool型におけるビット演算の挙動を調べるプログラム
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
#include <iostream> | |
using namespace std; | |
int main(int argc, char const* argv[]){ | |
bool ands[4] = {true & true, true & false, false & true, false & false}; | |
bool ors[4] = {true | true, true | false, false | true, false | false}; | |
cout << "ands: "; | |
for (int i = 0; i < 4; i++) cout << std::boolalpha << ands[i] << " "; | |
cout << endl; | |
cout << "ors: "; | |
for (int i = 0; i < 4; i++) cout << std::boolalpha << ors[i] << " "; | |
cout << endl; | |
bool and_substitute = true; and_substitute &= false; | |
bool or_substitute = true; or_substitute |= false; | |
cout << "and_substitute: " << std::boolalpha << and_substitute << endl; | |
cout << "or_substitute: " << std::boolalpha << or_substitute << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
出力結果