在蓝牙开发中经常需要字节转十进制。

  static int twoByteToIn(List<int> list){
    int high = list[0] & 0xFF;
    int low = list[1] & 0xFF;
    return (high << 8) | low;
  }

  static int fourByteToIn(List<int> list){
    int b0 = list[0] & 0xFF;
    int b1 = list[1] & 0xFF;
    int b2 = list[2] & 0xFF;
    int b3 = list[3] & 0xFF;
    return (b0 << 24) | (b1 << 16) | (b2 << 8) | b3;
  }



更多推荐