code: public static long saturatedMultiply(long a, long b) {
          // see checkedMultiply for explanation
          int leadingZeros = Long.numberOfLeadingZeros(a) + Long.numberOfLeadingZeros(~a) + Long.numberOfLeadingZeros(b) + Long.numberOfLeadingZeros(~b);
          if (leadingZeros > Long.SIZE + 1) {
              return a * b;
          }
          // the return value if we will overflow (which we calculate by overflowing a long :) )
          long limit = Long.MAX_VALUE + ((a ^ b) >>> (Long.SIZE - 1));
          if (leadingZeros < Long.SIZE | (a < 0 & b == Long.MIN_VALUE)) {
              // overflow
              return limit;
          }
          long result = a * b;
          if (a == 0 || result / a == b) {
              return result;
          }
          return limit;
      }
docs: Returns the product of {@code a} and {@code b} unless it would overflow or underflow in which
  case {@code Long.MAX_VALUE} or {@code Long.MIN_VALUE} is returned, respectively.
  
  @since 20.0