# python # 将数字变成0101数据(python) def numberTo16Bit(bdata): byte_arry = [0]*16 for i in range(0, len(byte_arry)): va = bdata & 1 byte_arry[i] = bdata & 1 bdata = bdata >> 1 return byte_arry
# java版
/** * 将十进制数转换成8个bit * @param b 将字节转换成二进制数据bit * @return */ public byte[] byteTo8Bit(byte b) { byte[] array = new byte[8]; for (int i = 7; i >= 0; i--) { array[i] = (byte)(b & 1); b = (byte) (b >> 1); } return array; }