byte merge (II)

Hi,

Following from an earlier post, I wish to merge bytes b1 & b2:

b1 = 1 (0000 0001)

b2 = 7 (0000 0111)

and when I merge them, I need the result: 0000 0001 0000 0111 (263). I got a reply to apply 256 * XOR operator on byte number and add the results. I did that and got the value 1:

byte b1 = 1;

byte b2 = 7;

b1 = (byte) (b1 * (256^1));

b2 = (byte) (b2 * (256^0));

System.out.println("b's = " + (b2 + b1));

can the author enlighten me on what I doing worng, or someone suggest an algorithm to do this should-be easy merge?

thanks

[610 byte] By [pwallacea] at [2007-10-2 0:16:07]
# 1
result = (256 * b1) + b2
ChuckBinga at 2007-7-15 16:17:29 > top of Java-index,Java Essentials,Java Programming...
# 2
thanks, I have also found:int result1 = ((b1 << 8) | b2); (big endian) orint result2 = ( b1 | (b2 << 8)) (little endian)
pwallacea at 2007-7-15 16:17:29 > top of Java-index,Java Essentials,Java Programming...