Here you can find the source of maskBits(BigInteger value, int bits)
public static BigInteger maskBits(BigInteger value, int bits)
//package com.java2s; //License from project: Open Source License import java.math.BigInteger; public class Main { public static BigInteger maskBits(BigInteger value, int bits) { BigInteger mask = BigInteger.ONE.shiftLeft(bits).subtract(BigInteger.ONE); return value.and(mask); }//from w w w. j a v a2s . c o m }