@Test public void testNegativeByte(){ byte val = -125; BitReader reader = new BitReader(new byte[]{val}); byte res = reader.readByte(); assertEquals(val, res); }
public byte readByte(){ if(bits % 8 == 0){ int i = bits / 8; bits += 8; return data[i]; } byte tmp = 0; for(int j=0; j<8; j++){ tmp = (byte) (tmp << 1); boolean k = readBoolean(); if(k){ tmp |= 1; } } return tmp; }
BitReader { public byte readByte(){ if(bits % 8 == 0){ int i = bits / 8; bits += 8; return data[i]; } byte tmp = 0; for(int j=0; j<8; j++){ tmp = (byte) (tmp << 1); boolean k = readBoolean(); if(k){ tmp |= 1; } } return tmp; } }
BitReader { public byte readByte(){ if(bits % 8 == 0){ int i = bits / 8; bits += 8; return data[i]; } byte tmp = 0; for(int j=0; j<8; j++){ tmp = (byte) (tmp << 1); boolean k = readBoolean(); if(k){ tmp |= 1; } } return tmp; } BitReader(byte[] data); }
BitReader { public byte readByte(){ if(bits % 8 == 0){ int i = bits / 8; bits += 8; return data[i]; } byte tmp = 0; for(int j=0; j<8; j++){ tmp = (byte) (tmp << 1); boolean k = readBoolean(); if(k){ tmp |= 1; } } return tmp; } BitReader(byte[] data); byte readByte(); boolean readBoolean(); int readInt(); int readInt(int nbits); char readChar(); }
BitReader { public byte readByte(){ if(bits % 8 == 0){ int i = bits / 8; bits += 8; return data[i]; } byte tmp = 0; for(int j=0; j<8; j++){ tmp = (byte) (tmp << 1); boolean k = readBoolean(); if(k){ tmp |= 1; } } return tmp; } BitReader(byte[] data); byte readByte(); boolean readBoolean(); int readInt(); int readInt(int nbits); char readChar();  }