Bit Flipper 2: A new hope oder so 🐬

This commit is contained in:
Simon Freiermuth 2022-03-17 15:32:27 +01:00
parent d631848d83
commit c24b5ee75e
2 changed files with 13 additions and 4 deletions

Binary file not shown.

View File

@ -62,13 +62,22 @@ public class SPN {
}
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;
int tmpA = (x & (0x1 << (15 - a)));
int tmpB = (x & (0x1 << (15 - b)));
tmpA = tmpA == 0 ? 0 : 1;
tmpB = tmpB == 0 ? 0 : 1;
x = tmpA == 0 ? (x & 0x1 << 15 - b) & 0b0 : (x & 0x1 << 15 - b) & ~0b0;
tmpA = tmpA << (15 -b);
tmpB = tmpB << (15 - a);
x = x | tmpA;
x = x | tmpB;
return 0;
// x = tmpA == 0 ? (x & 0x1 << 15 - b) | 0b0 : (x & 0x1 << 15 - b) | ~0b0;
// x = tmpB == 0 ? (x & 0x1 << 15 - a) | 0b0 : (x & 0x1 << 15 - a) | ~0b0;
return x;
}
}