Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. #include <iostream>
  2. #include <bitset>
  3.  
  4. using namespace std;
  5.  
  6. int number = 114;
  7.  
  8. void cleanFifthBit (){
  9.     bitset<32> numberBits = number;
  10.  
  11.     cout << "Stara stoinost: " << numberBits.to_ulong() << endl;
  12.  
  13.     numberBits[4] = 0; // chistim 5tiq bit ot dqsno na lqvo.. indexite zapochvat ot 0
  14.  
  15.     cout << "Nova stoinost: " << numberBits.to_ulong() << endl;
  16. }
  17.  
  18. //3ti i 4ti bit ot dqsno na lqvo da e 1ca
  19. void setBitCouple(){
  20.     bitset<32> numberBits = number;
  21.  
  22.  
  23.     cout << "Stara stoinost: " << numberBits.to_ulong() << endl;
  24.  
  25.     numberBits[2] = 1;
  26.     numberBits[3] = 1;
  27.  
  28.     cout << "Nova stoinost: " << numberBits.to_ulong();
  29. }
  30.  
  31. int main(){
  32.  
  33.     cleanFifthBit();
  34.     setBitCouple();
  35.  
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement