1.无符号byte, 实现了将byte(-128~127) 转换为 (0~255)

class UnsignedByte {
    private short value;
    private byte rawValue;

    private UnsignedByte() {
    }

    public static UnsignedByte toUnsignedByte(byte b) {
        UnsignedByte ub = new UnsignedByte();
        ub.rawValue = b;
        ub.value = (short) ((short) b & 0xFF);

        return ub;
    }

    public static byte toByte(UnsignedByte b) {
        return b.rawValue;
    }

    public static byte toByte(short i) {
        return (byte)i;
    }
}

 

相关文章:

  • 2022-12-23
  • 2021-07-15
  • 2022-12-23
  • 2021-11-14
  • 2021-07-18
  • 2021-05-19
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-16
  • 2022-12-23
  • 2022-01-27
  • 2022-12-23
  • 2022-12-23
  • 2021-10-13
  • 2022-12-23
相关资源
相似解决方案