Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 38 for Log2 (0.05 sec)

  1. android/guava-tests/test/com/google/common/math/DoubleMathTest.java

          int log2 = DoubleMath.log2(d, FLOOR);
          assertTrue(StrictMath.pow(2.0, log2) <= d);
          assertTrue(StrictMath.pow(2.0, log2 + 1) > d);
        }
      }
    
      @GwtIncompatible // DoubleMath.log2(double, RoundingMode), StrictMath
      public void testRoundLog2Ceiling() {
        for (double d : POSITIVE_FINITE_DOUBLE_CANDIDATES) {
          int log2 = DoubleMath.log2(d, CEILING);
    Registered: Wed Jun 12 16:38:11 UTC 2024
    - Last Modified: Wed Feb 07 17:50:39 UTC 2024
    - 28.1K bytes
    - Viewed (0)
  2. guava/src/com/google/common/math/BigIntegerMath.java

         * definitely >= floor(sqrt(x)), and then continue the iteration until we reach a fixed point.
         */
        BigInteger sqrt0;
        int log2 = log2(x, FLOOR);
        if (log2 < Double.MAX_EXPONENT) {
          sqrt0 = sqrtApproxWithDoubles(x);
        } else {
          int shift = (log2 - DoubleUtils.SIGNIFICAND_BITS) & ~1; // even!
          /*
           * We have that x / 2^shift < 2^54. Our initial approximation to sqrtFloor(x) will be
    Registered: Wed Jun 12 16:38:11 UTC 2024
    - Last Modified: Wed Feb 07 17:50:39 UTC 2024
    - 18.9K bytes
    - Viewed (0)
  3. android/guava/src/com/google/common/math/BigIntegerMath.java

         * definitely >= floor(sqrt(x)), and then continue the iteration until we reach a fixed point.
         */
        BigInteger sqrt0;
        int log2 = log2(x, FLOOR);
        if (log2 < Double.MAX_EXPONENT) {
          sqrt0 = sqrtApproxWithDoubles(x);
        } else {
          int shift = (log2 - DoubleUtils.SIGNIFICAND_BITS) & ~1; // even!
          /*
           * We have that x / 2^shift < 2^54. Our initial approximation to sqrtFloor(x) will be
    Registered: Wed Jun 12 16:38:11 UTC 2024
    - Last Modified: Wed Feb 07 17:50:39 UTC 2024
    - 18.9K bytes
    - Viewed (0)
  4. android/guava-tests/test/com/google/common/math/BigIntegerMathTest.java

        }
      }
    
      // Relies on the correctness of log2(BigInteger, {HALF_UP,HALF_DOWN}).
      public void testLog2HalfEven() {
        for (BigInteger x : POSITIVE_BIGINTEGER_CANDIDATES) {
          int halfEven = BigIntegerMath.log2(x, HALF_EVEN);
          // Now figure out what rounding mode we should behave like (it depends if FLOOR was
          // odd/even).
          boolean floorWasEven = (BigIntegerMath.log2(x, FLOOR) & 1) == 0;
    Registered: Wed Jun 12 16:38:11 UTC 2024
    - Last Modified: Fri May 17 17:58:33 UTC 2024
    - 27.8K bytes
    - Viewed (0)
  5. android/guava-tests/test/com/google/common/math/IntMathTest.java

            }
          }
        }
      }
    
      // Relies on the correctness of BigIntegerMath.log2 for all modes except UNNECESSARY.
      public void testLog2MatchesBigInteger() {
        for (int x : POSITIVE_INTEGER_CANDIDATES) {
          for (RoundingMode mode : ALL_SAFE_ROUNDING_MODES) {
            assertEquals(BigIntegerMath.log2(valueOf(x), mode), IntMath.log2(x, mode));
          }
        }
      }
    
      // Relies on the correctness of isPowerOfTwo(int).
    Registered: Wed Jun 12 16:38:11 UTC 2024
    - Last Modified: Wed Feb 07 17:50:39 UTC 2024
    - 24.5K bytes
    - Viewed (0)
  6. android/guava/src/com/google/common/math/DoubleMath.java

       * </ul>
       *
       * <p>The computed result is within 1 ulp of the exact result.
       *
       * <p>If the result of this method will be immediately rounded to an {@code int}, {@link
       * #log2(double, RoundingMode)} is faster.
       */
      public static double log2(double x) {
        return log(x) / LN_2; // surprisingly within 1 ulp according to tests
      }
    
      /**
    Registered: Wed Jun 12 16:38:11 UTC 2024
    - Last Modified: Wed Feb 07 17:50:39 UTC 2024
    - 18.9K bytes
    - Viewed (0)
  7. guava/src/com/google/common/math/DoubleMath.java

       * </ul>
       *
       * <p>The computed result is within 1 ulp of the exact result.
       *
       * <p>If the result of this method will be immediately rounded to an {@code int}, {@link
       * #log2(double, RoundingMode)} is faster.
       */
      public static double log2(double x) {
        return log(x) / LN_2; // surprisingly within 1 ulp according to tests
      }
    
      /**
    Registered: Wed Jun 12 16:38:11 UTC 2024
    - Last Modified: Wed Feb 07 17:50:39 UTC 2024
    - 18.9K bytes
    - Viewed (0)
  8. guava/src/com/google/common/math/IntMath.java

         *
         * The key idea is that based on the number of leading zeros (equivalently, floor(log2(x))), we
         * can narrow the possible floor(log10(x)) values to two. For example, if floor(log2(x)) is 6,
         * then 64 <= x < 128, so floor(log10(x)) is either 1 or 2.
         */
        int y = maxLog10ForLeadingZeros[Integer.numberOfLeadingZeros(x)];
        /*
    Registered: Wed Jun 12 16:38:11 UTC 2024
    - Last Modified: Wed Feb 07 17:50:39 UTC 2024
    - 23.5K bytes
    - Viewed (0)
  9. android/guava/src/com/google/common/math/IntMath.java

         *
         * The key idea is that based on the number of leading zeros (equivalently, floor(log2(x))), we
         * can narrow the possible floor(log10(x)) values to two. For example, if floor(log2(x)) is 6,
         * then 64 <= x < 128, so floor(log10(x)) is either 1 or 2.
         */
        int y = maxLog10ForLeadingZeros[Integer.numberOfLeadingZeros(x)];
        /*
    Registered: Wed Jun 12 16:38:11 UTC 2024
    - Last Modified: Wed Feb 07 17:50:39 UTC 2024
    - 23.5K bytes
    - Viewed (0)
  10. guava-tests/test/com/google/common/math/LongMathTest.java

      /* Relies on the correctness of BigIntegerMath.log2 for all modes except UNNECESSARY. */
      public void testLog2MatchesBigInteger() {
        for (long x : POSITIVE_LONG_CANDIDATES) {
          for (RoundingMode mode : ALL_SAFE_ROUNDING_MODES) {
            // The BigInteger implementation is tested separately, use it as the reference.
            assertEquals(BigIntegerMath.log2(valueOf(x), mode), LongMath.log2(x, mode));
          }
        }
      }
    
    Registered: Wed Jun 12 16:38:11 UTC 2024
    - Last Modified: Mon Mar 04 20:15:57 UTC 2024
    - 32.5K bytes
    - Viewed (0)
Back to top