Java BigInteger Calculate int2zpBin(BigInteger num, int len)

Here you can find the source of int2zpBin(BigInteger num, int len)

Description

intzp Bin

License

BSD License

Declaration

public static String int2zpBin(BigInteger num, int len) 

Method Source Code

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

import java.math.BigInteger;

public class Main {
    public static String int2zpBin(int num, int len) {
        final String zeroPadding = rep('0', len);
        final String numString = Integer.toBinaryString(num);
        return (zeroPadding.substring(numString.length()) + numString);
    }/*from  w w w  .  ja  va 2  s. c om*/

    public static String int2zpBin(BigInteger num, int len) {
        final String zeroPadding = rep('0', len);
        final String numString = num.toString(2);
        return (zeroPadding.substring(numString.length()) + numString);
    }

    public static String rep(char c, int n) {
        return new String(new char[n]).replace('\0', c);
    }
}

Related

  1. getValueWithUnit(BigInteger value, final int places)
  2. getVersionString(BigInteger versionNumber)
  3. greater(BigInteger i1, BigInteger i2)
  4. hexEncode(BigInteger bigInteger)
  5. increment(BigInteger integer)
  6. integerToString(BigInteger value)
  7. intValue(BigInteger bi)
  8. intValueExact(BigInteger bigint)
  9. jsonBigInteger(JsonValue value)