Schupp

shift test 9Bit

Mar 22nd, 2021
806
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. /******************************************************************************
  2.  
  3.                               Online C++ Compiler.
  4.                Code, Compile, Run and Debug C++ program online.
  5. Write your code in this editor and press "Run" button to compile and execute it.
  6.  
  7. *******************************************************************************/
  8.  
  9. #include <iostream>
  10. #include <bitset>
  11. using namespace std;
  12.  
  13. int main()
  14. {
  15.     uint16_t test1 = 255;
  16.     uint16_t test2 = 128;
  17.     uint16_t result= test1;
  18.     result = test1+((test2 &128)<<1);
  19.     std::cout << "a = " << std::bitset<8>(test1)  << std::endl;
  20.     std::cout << "a = " << std::bitset<8>(test2)  << std::endl;
  21.     std::cout << "a = " << std::bitset<16>(result)  << std::endl;
  22.     std::cout << "a = " << result  << std::endl;
  23.     cout<<"Hello World";
  24.  
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment