Hey guys. So, I have a piece of code that works:
public static boolean[] sub(int a) { assert (a >= 0 && a <= 7); boolean uread = false, uwrite = false, uexecute = false; switch (a) { case 0: uread = false; uwrite = false; uexecute = false; break; case 1: uread = false; uwrite = false; uexecute = true; break; case 2: uread = false; uwrite = true; uexecute = false; break; case 3: uread = false; uwrite = true; uexecute = true; break; case 4: uread = true; uwrite = false; uexecute = false; break; case 5: uread = true; uwrite = false; uexecute = true; break; case 6: uread = true; uwrite = true; uexecute = false; break; case 7: uread = true; uwrite = true; uexecute = true; break; } return new boolean[] { uread, uwrite, uexecute }; }
I am 99 percent sure that can be done using shifts and other binary operations. My question is how?