Java Bit Count bitLength(final int byteLength)

Here you can find the source of bitLength(final int byteLength)

Description

Returns the bit length of the specified byte length.

License

Apache License

Parameter

Parameter Description
byteLength The byte length.

Return

The bit length.

Declaration

public static int bitLength(final int byteLength) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**/*from w w w .  j  av  a 2 s . co  m*/
     * Returns the bit length of the specified byte length.
     *
     * @param byteLength The byte length.
     *
     * @return The bit length.
     */
    public static int bitLength(final int byteLength) {

        return byteLength * 8;
    }

    /**
     * Returns the byte length of the specified byte array.
     *
     * @param byteArray The byte array. May be {@code null}.
     *
     * @return The bite length, zero if the array is {@code null}.
     */
    public static int bitLength(final byte[] byteArray) {

        if (byteArray == null) {
            return 0;
        } else {
            return bitLength(byteArray.length);
        }
    }
}

Related

  1. bitcount(int num)
  2. bitCount(int x)
  3. bitCount(String s)
  4. bitCountSlow(int x)
  5. bitLength(byte[] bytes)
  6. bitLength(int num)
  7. bitLength(int value)
  8. bitSizeForSignedValue(final int value)
  9. bitSizeForUnsignedValue(final int value)