@Test void testDecodeExampleD_1_3() { ByteBuffer buf = ByteBuffer.wrap(TypeUtils.fromHexString("882aFf")); buf.position(1); assertEquals(42, NBitInteger.decode(buf, 8)); }
public static int decode(ByteBuffer buffer, int n) { if (n == 8) { int nbits = 0xFF; int i = buffer.get() & 0xff; if (i == nbits) { int m = 1; int b; do { b = 0xff & buffer.get(); i = i + (b & 127) * m; m = m * 128; } while ((b & 128) == 128); } return i; } int nbits = 0xFF >>> (8 - n); int i = buffer.get(buffer.position() - 1) & nbits; if (i == nbits) { int m = 1; int b; do { b = 0xff & buffer.get(); i = i + (b & 127) * m; m = m * 128; } while ((b & 128) == 128); } return i; }
NBitInteger { public static int decode(ByteBuffer buffer, int n) { if (n == 8) { int nbits = 0xFF; int i = buffer.get() & 0xff; if (i == nbits) { int m = 1; int b; do { b = 0xff & buffer.get(); i = i + (b & 127) * m; m = m * 128; } while ((b & 128) == 128); } return i; } int nbits = 0xFF >>> (8 - n); int i = buffer.get(buffer.position() - 1) & nbits; if (i == nbits) { int m = 1; int b; do { b = 0xff & buffer.get(); i = i + (b & 127) * m; m = m * 128; } while ((b & 128) == 128); } return i; } }
NBitInteger { public static int decode(ByteBuffer buffer, int n) { if (n == 8) { int nbits = 0xFF; int i = buffer.get() & 0xff; if (i == nbits) { int m = 1; int b; do { b = 0xff & buffer.get(); i = i + (b & 127) * m; m = m * 128; } while ((b & 128) == 128); } return i; } int nbits = 0xFF >>> (8 - n); int i = buffer.get(buffer.position() - 1) & nbits; if (i == nbits) { int m = 1; int b; do { b = 0xff & buffer.get(); i = i + (b & 127) * m; m = m * 128; } while ((b & 128) == 128); } return i; }  }
NBitInteger { public static int decode(ByteBuffer buffer, int n) { if (n == 8) { int nbits = 0xFF; int i = buffer.get() & 0xff; if (i == nbits) { int m = 1; int b; do { b = 0xff & buffer.get(); i = i + (b & 127) * m; m = m * 128; } while ((b & 128) == 128); } return i; } int nbits = 0xFF >>> (8 - n); int i = buffer.get(buffer.position() - 1) & nbits; if (i == nbits) { int m = 1; int b; do { b = 0xff & buffer.get(); i = i + (b & 127) * m; m = m * 128; } while ((b & 128) == 128); } return i; }  static int octectsNeeded(int n, int i); static void encode(ByteBuffer buf, int n, int i); static int decode(ByteBuffer buffer, int n); }
NBitInteger { public static int decode(ByteBuffer buffer, int n) { if (n == 8) { int nbits = 0xFF; int i = buffer.get() & 0xff; if (i == nbits) { int m = 1; int b; do { b = 0xff & buffer.get(); i = i + (b & 127) * m; m = m * 128; } while ((b & 128) == 128); } return i; } int nbits = 0xFF >>> (8 - n); int i = buffer.get(buffer.position() - 1) & nbits; if (i == nbits) { int m = 1; int b; do { b = 0xff & buffer.get(); i = i + (b & 127) * m; m = m * 128; } while ((b & 128) == 128); } return i; }  static int octectsNeeded(int n, int i); static void encode(ByteBuffer buf, int n, int i); static int decode(ByteBuffer buffer, int n);  }