Java BigInteger Calculate log2(BigInteger x)

Here you can find the source of log2(BigInteger x)

Description

log

License

Open Source License

Declaration

public static int log2(BigInteger x) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.math.BigInteger;

public class Main {
    public static int log2(BigInteger x) {
        return x.bitLength() - 1;
    }//from w ww .  j a  v  a2 s  .com

    public static int log2(int x) {
        return (Integer.SIZE - 1) - Integer.numberOfLeadingZeros(x);
    }
}

Related

  1. intValue(BigInteger bi)
  2. intValueExact(BigInteger bigint)
  3. jsonBigInteger(JsonValue value)
  4. length(BigInteger bi)
  5. listToBigInteger(List list)
  6. maskBits(BigInteger value, int bits)
  7. min(BigInteger a, BigInteger b)
  8. modPow(BigInteger base, BigInteger e, BigInteger m)
  9. modPowByte(byte[] arg, BigInteger e, BigInteger n)