Possible Duplicate:
Convert 4 bytes to int
I'm trying to pack 4 bytes into an int using some of the solutions found here, but it doesn't seem to work for one of my tests.
This is the code I'm using:
public static int pack(int c1, int c2, int c3, int c4)
{
return (c1 << 24) | (c2 << 16) | (c3 << 8) | (c4);
}
Now when I use it on something simple like 0x34, 0x68, 0x77, and 0x23 I get what I expect: 0x34687723. But when I use it on 0xBA, 0xAD, 0xBE, and 0xEF I get something way off. Does anyone see what the problem might be?
EDIT
The above code was able to give me what I wanted, and the "wrong value" I mention below is just another way of representing 0xBAADBEEF in a decimal form.