Java BigInteger Calculate distance(BigInteger a, BigInteger b)

Here you can find the source of distance(BigInteger a, BigInteger b)

Description

distance

License

Open Source License

Declaration

public static int distance(BigInteger a, BigInteger b) 

Method Source Code


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

import java.math.BigInteger;

public class Main {
    public static int M;

    public static int distance(BigInteger a, BigInteger b) {
        int ia = a.intValue();
        int ib = b.intValue();
        if (ib >= ia)
            return ib - ia;
        return ib + (int) Math.pow(2, M) - ia;

    }//from ww  w. ja  v  a 2 s . co  m
}

Related

  1. decodeBitListFromBigInteger(BigInteger bits)
  2. decodeFloat(BigInteger rawSign, BigInteger rawExponent, BigInteger rawMantissa, int signWidth, int exponentWidth, int mantissaWidth, int bias, MathContext mc)
  3. decodeToBigInteger(String input)
  4. DiffieHellman(BigInteger p, BigInteger g, BigInteger x, BigInteger y, BigInteger y_B)
  5. distance(BigInteger a, BigInteger b)
  6. div(BigInteger dividend, BigInteger divisor)
  7. divide(BigInteger dividend, BigInteger divisor)
  8. dump(BigInteger x)
  9. dumpBitLengthOfValues(BigInteger... data)