knyazer

9

Jan 18th, 2021
702
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int myMethod(int x)
  2. {
  3.     int sz = 0;
  4.     for (int i = 0; i < 31; i++)
  5.         if ((x & (1 << i)) != 0)
  6.             sz = i + 1;
  7.     int mask = 0;
  8.     for (int i = 0; i < sz / 2; i++)
  9.         mask |= (1 << i);
  10.     return (x >> (sz / 2)) + ((x & mask) << (sz / 2));
  11. }
RAW Paste Data