In 3 operations how can I turn a byte into a 32 bit int that matches this:
0x1fffe
I can only explicitly access a byte at a time thus I start with 0xFF and then shift it.
I can do it using 4 operations but I cant find a way to eliminate one operation.
int mask2 = 0xFF << 8;
mask2 = mask2 | 0xFE;
mask2 = mask2 + mask2;
mask2 = mask2 | 0x02;
Any ideas?
In other words, I need a mask, 0x1FFFE to be made in 3 operations while only accessing a byte at a time like the example.
Maybe this is what you want… you start with one single byte value (0xff), and you work on it with 3 bitwise operations, obtaining 0x1fffe.