int x=123;
byte[] bitstr=new byte[4];
bitstr[0]=(byte)(x&ff000000);
bitstr[1]=(byte)(x&00ff0000);
bitstr[2]=(byte)(x&0000ff00);
bitstr[3]=(byte)(x&000000ff);
byte[] bitstr=new byte[4];
bitstr[0]=(byte)(x&ff000000);
bitstr[1]=(byte)(x&00ff0000);
bitstr[2]=(byte)(x&0000ff00);
bitstr[3]=(byte)(x&000000ff);
byteArray[0] = myint;
byteArray[1] = myint>>1;
byteArray[2] = myint>>2;
byteArray[3] = myint>>3;
應該:
int x=123;
byte[] bitstr=new byte[4];
bitstr[0]=(byte)(x&0xff000000);
.......
應該:
int x=123;
byte[] bitstr=new byte[4];
bitstr[0]=(byte)(x&0xff000000);
bytes [0]=(byte)( (myInt >>> 24 ) 0xff);
bytes [1]=(byte)( (myInt >>> 16 ) 0xff);
bytes [2]=(byte)( (myInt >>> 8 ) 0xff);
bytes [3]=(byte)( (myInt >>> 0 ) 0xff);
bytes [0]=(byte)( (myInt >>> 24 ) 0xff);
bytes [1]=(byte)( (myInt >>> 16 ) 0xff);
bytes [2]=(byte)( (myInt >>> 8 ) 0xff);
bytes [3]=(byte)( (myInt >>> 0 ) 0xff);
。
byte[] bytes = new byte[4];
bytes [0]=(byte)( (myInt >>> 24 ) && 0xff);
bytes [1]=(byte)( (myInt >>> 16 ) && 0xff);
bytes [2]=(byte)( (myInt >>> 8 ) && 0xff);
bytes [3]=(byte)( (myInt >>> 0 ) && 0xff);