daily pastebin goal
0%
SHARE
TWEET

Untitled

a guest Feb 11th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.             uint given = 75;
  2.             Console.WriteLine(Convert.ToString(given, 2));
  3.             int len = Convert.ToString(given, 2).Length;
  4.  
  5.             for (int i = 0; i < len; i++)
  6.             {
  7.                 uint mask = (uint)1 << i;
  8.                 if ((given & mask) == 0)  //the i-th bit is unset
  9.                 {
  10.                     given = given | mask; //set
  11.                 }
  12.                 else  //the i-th bit is set
  13.                 {
  14.                     given = given & (~mask);
  15.                 }
  16.             }
  17.             Console.WriteLine(Convert .ToString (given ,2));
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top