code: @SuppressWarnings("fallthrough")
      public static int log2(double x, RoundingMode mode) {
          N.checkArgument(x > 0.0 && isFinite(x), "x must be positive and finite");
          int exponent = getExponent(x);
          if (!isNormal(x)) {
              return log2(x * IMPLICIT_BIT, mode) - SIGNIFICAND_BITS;
              // Do the calculation on a normal value.
          }
          // x is positive, finite, and normal
          boolean increment;
          switch (mode) {
              case UNNECESSARY:
                  checkRoundingUnnecessary(isPowerOfTwo(x));
                  // fall through
              case FLOOR:
                  increment = false;
                  break;
              case CEILING:
                  increment = !isPowerOfTwo(x);
                  break;
              case DOWN:
                  increment = exponent < 0 & !isPowerOfTwo(x);
                  break;
              case UP:
                  increment = exponent >= 0 & !isPowerOfTwo(x);
                  break;
              case HALF_DOWN:
              case HALF_EVEN:
              case HALF_UP:
                  double xScaled = scaleNormalize(x);
                  // sqrt(2) is irrational, and the spec is relative to the "exact numerical result,"
                  // so log2(x) is never exactly exponent + 0.5.
                  increment = (xScaled * xScaled) > 2.0;
                  break;
              default:
                  throw new AssertionError();
          }
          return increment ? exponent + 1 : exponent;
      }
docs: Returns the base 2 logarithm of a double value, rounded with the specified rounding mode to an
  {@code int}.
  
  <p>Regardless of the rounding mode, this is faster than {@code (int) log2(x)}.
  
  @throws IllegalArgumentException if {@code x <= 0.0}, {@code x} is NaN, or {@code x} is
  infinite