private static boolean isValidBitCount(int mBitSize, int nBitSize, BigInteger value) { return value.bitCount() <= mBitSize + nBitSize; }
private String fromAddress(String s) { if (s == null) return null; s = del0X(s); BigInteger i = new BigInteger(s, 16); if (i.bitCount() > 0) { return s; } return null; }
@GwtIncompatible // java.math.BigInteger public void testIsPowerOfTwo() { for (int x : ALL_INTEGER_CANDIDATES) { // Checks for a single bit set. BigInteger bigX = BigInteger.valueOf(x); boolean expected = (bigX.signum() > 0) && (bigX.bitCount() == 1); assertEquals(expected, IntMath.isPowerOfTwo(x)); } }
@GwtIncompatible // java.math.BigInteger public void testIsPowerOfTwo() { for (long x : ALL_LONG_CANDIDATES) { // Checks for a single bit set. BigInteger bigX = BigInteger.valueOf(x); boolean expected = (bigX.signum() > 0) && (bigX.bitCount() == 1); assertEquals(expected, LongMath.isPowerOfTwo(x)); } }
int rp_bc = this.rp.bitCount(); if ((this.rp.bitLength() != (m+1)) || (rp_bc != TPB_LEN && rp_bc != PPB_LEN) ||
public static void main(String[] args) { String a = "1001101111101011011100101100100110111011111011000100111100111110111101011011011100111001100011111010"; int x = new BigInteger(a, 2).bitCount(); System.out.println(x); }
private static final BigInteger FOUR = new BigInteger("4"); public boolean binaryStringIsOK(final String input) { final BigInteger b; try { b = new BigInteger(inputString, 2); return b.mod(FOUR).equals(BigInteger.ZERO) && b.bitCount() >= 3; } catch (NumberException ignored) { return false; } }
import java.math.BigInteger; public class BigIntegerTest { public static void main(String[] args) { BigInteger b1 = new BigInteger("200000000000000000000000000000000001"); BigInteger b2 = new BigInteger("400000000000000000000000000000000000"); System.out.println(b1.multiply(b2)); System.out.println(b1.bitCount()); System.out.println(b1.pow(13)); } }
public static int numberOfMatchingOnes(String a, String b) { BigInteger aNumber = new BigInteger(a, 16); BigInteger bNumber = new BigInteger(b, 16); return aNumber.xor(bNumber).bitCount(); }
public static int getNafWeight(BigInteger k) { if (k.signum() == 0) { return 0; } BigInteger _3k = k.shiftLeft(1).add(k); BigInteger diff = _3k.xor(k); return diff.bitCount(); }
/** * Count bits that both bits are 1. */ public IntWritable evaluate(String a, String b) { BigInteger ai = new BigInteger(a); BigInteger bi = new BigInteger(b); BigInteger innerProduct = ai.and(bi); return val(innerProduct.bitCount()); }
public static int getNafWeight(BigInteger k) { if (k.signum() == 0) { return 0; } BigInteger _3k = k.shiftLeft(1).add(k); BigInteger diff = _3k.xor(k); return diff.bitCount(); }
@Override public int hashCode() { byte[] bytes = name.toString().getBytes(); BigInteger bigInt = new BigInteger(bytes); int val = bigInt.bitCount()+bigInt.intValue(); return val+idx; }
public static int getNafWeight(BigInteger k) { if (k.signum() == 0) { return 0; } BigInteger _3k = k.shiftLeft(1).add(k); BigInteger diff = _3k.xor(k); return diff.bitCount(); }
public static int hammingDistance(final BigInteger a, final BigInteger b) { BigInteger xor = a.xor(b); return xor.bitCount(); }
@Override public BigInteger valInt() { BigInteger value = args.get(0).valInt(); if ((nullValue = args.get(0).isNullValue())) return BigInteger.ZERO; /* purecov: inspected */ return BigInteger.valueOf(value.bitCount()); }
static int bitCount( final int i ) { return java.math.BigInteger.valueOf(i).bitCount(); }
@GwtIncompatible // java.math.BigInteger public void testIsPowerOfTwo() { for (long x : ALL_LONG_CANDIDATES) { // Checks for a single bit set. BigInteger bigX = BigInteger.valueOf(x); boolean expected = (bigX.signum() > 0) && (bigX.bitCount() == 1); assertEquals(expected, LongMath.isPowerOfTwo(x)); } }