Number160 extends Number implements Comparable<Number160> { public int bitLength() { int bits = 0; for (int i = 0; i < INT_ARRAY_SIZE; i++) { if (this.val[i] != 0) { bits += Integer.SIZE - Integer.numberOfLeadingZeros(this.val[i]); bits += Integer.SIZE * (INT_ARRAY_SIZE - ++i); break; } } return bits; } Number160();  Number160(final int... val);  Number160(final String val);  Number160(final int val);  Number160(final long val);  Number160(final byte[] val);  Number160(final byte[] val, final int offset, final int length);  Number160(final Random random);  Number160(final long timestamp, Number160 number96); long timestamp(); Number160 number96(); Number160 xor(final Number160 key); int[] toIntArray(); int toByteArray(final byte[] me, final int offset); byte[] toByteArray(); String toString(final boolean removeLeadingZero); boolean isZero(); int bitLength(); @Override String toString(); @Override double doubleValue(); @Override float floatValue(); @Override int intValue(); @Override long longValue(); @Override int compareTo(final Number160 o); @Override boolean equals(final Object obj); @Override int hashCode(); static Number160 createHash(final int integerValue); static Number160 createHash(final long longValue); static Number160 createHash(final String string); static final int BITS; static final int INT_ARRAY_SIZE; static final int BYTE_ARRAY_SIZE; static final int CHARS_PER_INT; static final Number160 ZERO; static final Number160 ONE; static final Number160 MAX_VALUE; }
@Test public void testBitLength() { Number160 ki2 = Number160.ONE; Assert.assertEquals(1, ki2.bitLength()); ki2 = new Number160("0x2"); Assert.assertEquals(2, ki2.bitLength()); ki2 = new Number160("0x3"); Assert.assertEquals(2, ki2.bitLength()); ki2 = new Number160("0xfa"); Assert.assertEquals(8, ki2.bitLength()); ki2 = new Number160("0x100000002"); Assert.assertEquals(33, ki2.bitLength()); ki2 = new Number160("0x1100000002"); Assert.assertEquals(37, ki2.bitLength()); try { ki2 = new Number160("0x-1"); Assert.fail(); } catch (RuntimeException e) { } ki2 = Number160.MAX_VALUE; Assert.assertEquals(160, ki2.bitLength()); }