bit Flipper im the making 🐬

This commit is contained in:
Simon Freiermuth 2022-03-17 15:03:39 +01:00
parent 0851f73c88
commit d631848d83
4 changed files with 27 additions and 0 deletions

View file

@ -61,4 +61,14 @@ public class SPN {
return x;
}
public int swapBits(int x, int a, int b) {
int tmpA = (x & (0x1 << 15 - a)) == 0 ? 0 : 1;
int tmpB = (x & (0x1 << 15 - b)) == 0 ? 0 : 1;
x = tmpA == 0 ? (x & 0x1 << 15 - b) & 0b0 : (x & 0x1 << 15 - b) & ~0b0;
return 0;
}
}