byte abyte =-1; System.out.println(abyte); System.out.println(Integer.toBinaryString(abyte)); //取高四位 byte high = (byte) ((abyte>>4) & 0x0f); System.out.println("取高四位"+Integer.toBinaryString(high)); //取低四位 byte low = (byte) (abyte & 0x0f); System.out.println("取低四位"+Integer.toBinaryString(low)); //byte转int保持数值不变 int b= (int)abyte; System.out.println(b); //byte转int保持最低字节中各个位不变 int c= (int)(abyte & 0xff); System.out.println(c);
时间: 2024-11-06 07:18:55