I tried doing this in C:
int val = 0xCAFE;
int uc = val & 14;
if (val & 15 == 15 || val & 7 == 7 || val & 11 == 11|| val & 13 == 13 || val & 14 == 14){
printf("asdjfkadscjas \n");
}
However this is not printing the random string as it should. It worked for 15,7,11,13 tho.
If anyone knows of a better way that would be helpful. I am bad with bitwise operator.
Thanks
Alternative solution: You can put all your numbers into a binary-coded lookup table:
Each bit of the magic number represents an answer. In the constant 0xe880 bits 7,11,13,14 and 15 are set. You select the correct bit using a shift and mask it out.
It’s not as readable as your solution but faster..