检查64位BigInteger是否包含Java中的所有非零高32位?

Ror*_*ory 0 java math bit-manipulation biginteger bit

有人知道怎么做吗 -

检查64位BigInteger是否包含Java中的所有非零高32位?

谢谢!

Jon*_*eet 6

怎么样:

private static final BigInteger MASK = BigInteger.valueOf(0xffffffff)
                                                 .shiftLeft(32);

...

public static boolean top32BitsSet(BigInteger value) {
    return value.and(MASK).equals(MASK);
}
Run Code Online (Sandbox Code Playgroud)