code: @GwtIncompatible // #roundIntermediate
    public static long roundToLong(double x, RoundingMode mode) {
      double z = roundIntermediate(x, mode);
      checkInRangeForRoundingInputs(
          MIN_LONG_AS_DOUBLE - z < 1.0 & z < MAX_LONG_AS_DOUBLE_PLUS_ONE, x, mode);
      return (long) z;
    }
docs: Returns the {@code long} value that is equal to {@code x} rounded with the specified rounding
  mode, if possible.
  
  @throws ArithmeticException if
  <ul>
  <li>{@code x} is infinite or NaN
  <li>{@code x}, after being rounded to a mathematical integer using the specified rounding
  mode, is either less than {@code Long.MIN_VALUE} or greater than {@code
  Long.MAX_VALUE}
  <li>{@code x} is not a mathematical integer and {@code mode} is {@link
  RoundingMode#UNNECESSARY}
  </ul>