diff options
| author | Chanin Timbal <[email protected]> | 2024-06-01 11:49:52 -0700 |
|---|---|---|
| committer | Chanin Timbal <[email protected]> | 2024-06-01 11:49:52 -0700 |
| commit | ee299e40737932350f6b4b48a7380e2645089d45 (patch) | |
| tree | c33e828baa1951790771f05b051e912452302a5b /CST 126/In-class/bitwise_operators.cpp | |
| parent | Merge branch 'develop' of https://github.com/OIT-WI-2024/homework-1-chaninnoh... (diff) | |
| download | archived-homework-1-chaninnohea-ee299e40737932350f6b4b48a7380e2645089d45.tar.xz archived-homework-1-chaninnohea-ee299e40737932350f6b4b48a7380e2645089d45.zip | |
attempting rebuild
Diffstat (limited to 'CST 126/In-class/bitwise_operators.cpp')
| -rw-r--r-- | CST 126/In-class/bitwise_operators.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/CST 126/In-class/bitwise_operators.cpp b/CST 126/In-class/bitwise_operators.cpp new file mode 100644 index 0000000..65bb509 --- /dev/null +++ b/CST 126/In-class/bitwise_operators.cpp @@ -0,0 +1,35 @@ +//Bitwise Operators +#include <bitset> +#include <iostream> +#include <iomanip> + +using std::cout; +using std::cin; +using std::endl; +using std::bitset; + +int main(const int argc, char* argv[]) +{ + + int num = 0xABCD; + int mask = 0xFFF0; + int result = num & mask; + + bitset<16> binary_num(0x03); + bitset<16> binary_mask(0x03); + bitset<16> binary_result(0x03); + + cout << "Hex:\n"; + cout << "num = " << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << num << endl; + cout << "mask = " << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << num << endl; + cout << "result = " << "0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << num << endl; + + + cout << "Binary:\n"; + cout << binary_num << endl; + cout << binary_mask << endl; + cout << binary_result << endl; + + + return true; +}
\ No newline at end of file |