do these two pieces of code do the same thing? It doesn't seem like it to me: ``` void ubyteToRGB323(ubyte val, ubyte arr[3]) { // This looks really unoptimised, but I don't know how t optimise it arr[0] = 0; arr[1] = 0; arr[2] = 0; arr[0] += ((val >> 0) & 1) * 32; arr[0] += ((val >> 1) & 1) * 64; arr[0] += ((val >> 2) & 1) * 128; arr[1] += ((val >> 3) & 1) * 64; arr[1] += ((val >> 4) & 1) * 128; arr[2] += ((val >> 5) & 1) * 32; arr[2] += ((val >> 6) & 1) * 64; arr[2] += ((val >> 7) & 1) * 128; }, ``` ``` void ubyteToRGB323(ubyte val, ubyte arr[3]) { // Use bit masks to extract the relevant bits directly arr[0] = ((val & 0x07) shift left to 5, 6, 7 positions arr[1] = ((val & 0x18) shift left to 6, 7 positions arr[2] = ((val & 0xE0) >> 2); // Blue: bits 5, 6, 7 -> shift right to 3, 4, 5 positions }, ```
Have you tried to test them on their input set?