code: @GwtIncompatible
    public static BigInteger roundToBigInteger(double x, RoundingMode mode) {
      x = roundIntermediate(x, mode);
      if (MIN_LONG_AS_DOUBLE - x < 1.0 & x < MAX_LONG_AS_DOUBLE_PLUS_ONE) {
        return BigInteger.valueOf((long) x);
      }
      int exponent = getExponent(x);
      long significand = getSignificand(x);
      BigInteger result = BigInteger.valueOf(significand).shiftLeft(exponent - SIGNIFICAND_BITS);
      return (x < 0) ? result.negate() : result;
    }
docs: #roundIntermediate, java.lang.Math.getExponent, com.google.common.math.DoubleUtils