code: private static BigInteger toUnsignedBigInteger(long i) {
          if (i >= 0L)
              return BigInteger.valueOf(i);
          else {
              int upper = (int) (i >>> 32);
              int lower = (int) i;
  
              // return (upper << 32) + lower
              return (BigInteger.valueOf(Integer.toUnsignedLong(upper))).shiftLeft(32).
                  add(BigInteger.valueOf(Integer.toUnsignedLong(lower)));
          }
      }
docs: Return a BigInteger equal to the unsigned value of the
  argument.