Java BigInteger Calculate getNafWeight(BigInteger k)

Here you can find the source of getNafWeight(BigInteger k)

Description

get Naf Weight

License

Open Source License

Declaration

public static int getNafWeight(BigInteger k) 

Method Source Code

//package com.java2s;
import java.math.BigInteger;

public class Main {
    public static int getNafWeight(BigInteger k) {
        if (k.signum() == 0) {
            return 0;
        }/*  w w w  . java2 s .co  m*/

        BigInteger _3k = k.shiftLeft(1).add(k);
        BigInteger diff = _3k.xor(k);

        return diff.bitCount();
    }
}

Related

  1. getLongAsUnsignedBigInteger(long number)
  2. getMagnitude(BigInteger bi)
  3. getMetaDataForLPortDispatcher(int lportTag, short serviceIndex, BigInteger serviceMetaData)
  4. getMetaDataMaskForLPortDispatcher(BigInteger metadataMaskForServiceIndex, BigInteger metadataMaskForLPortTag, BigInteger metadataMaskForService)
  5. getN(BigInteger p, BigInteger q)
  6. getNatRouterIdFromMetadata(BigInteger metadata)
  7. getNetAddress(BigInteger ip, BigInteger netmask)
  8. getNextLexicographicalPermutation(BigInteger v)
  9. getNRightmostBits(final BigInteger in, final int n)