I have to write a method that takes in an integer as a parameter (0, 1, 2, or 3). I have to use that to create a bitmask with a 0. So, if the parameter is 0, than the bitmask will be FFF0
, for 1: FF0F
, 2: F0FF
, 3: 0FFF
. I am trying not to hardcode it.
What I have tried, but it only works partially:
int bob = 0xFFFF;
int multi = 2;
multi = multi << param;
this works with 1 and 2, and for even those, it makes it 0xFF00
, and 0xF000
.
I am trying not to use multiplication either (that would make it a lot easier, so I don't want to use it).