hi thanks in advance for your help, i am trying to write a program that will allow you to reorder the bytes in a integer i plan on separating the bytes with a filter like so
int number = 3;
int filter = Integer.parseInt("11111111000000000000000000000000",2);
return number & filter;
i wrote a switch statement to select between the four different filters
- first byte filter = "11111111000000000000000000000000"
- second byte filter = "00000000111111110000000000000000"
- third byte filter = "00000000000000001111111100000000"
- forth byte filter = "00000000000000000000000011111111"
the second to forth filters work but the first one throws a number format exception is this something to do with the sign of the integer?
after seperating the bytes like this i want to use left and right shift to move the bytes and use the OR bitwise operator to combine them back in to a 32 bit integer but in a different order thanks again for any help.