Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 1,273 for log2 (0.21 sec)

  1. android/guava/src/com/google/common/math/BigIntegerMath.java

        // Strip off 2s from this value.
        int shift = Long.numberOfTrailingZeros(product);
        product >>= shift;
    
        // Use floor(log2(num)) + 1 to prevent overflow of multiplication.
        int productBits = LongMath.log2(product, FLOOR) + 1;
        int bits = LongMath.log2(startingNumber, FLOOR) + 1;
        // Check for the next power of two boundary, to save us a CLZ operation.
        int nextPowerOfTwo = 1 << (bits - 1);
    
    Java
    - Registered: 2024-04-12 12:43
    - Last Modified: 2024-02-07 17:50
    - 18.9K bytes
    - Viewed (0)
  2. 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);
    Java
    - Registered: 2024-04-12 12:43
    - Last Modified: 2024-02-07 17:50
    - 28.1K bytes
    - Viewed (0)
  3. 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;
    Java
    - Registered: 2024-04-12 12:43
    - Last Modified: 2024-02-07 17:50
    - 28.2K bytes
    - Viewed (0)
  4. 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;
    Java
    - Registered: 2024-04-12 12:43
    - Last Modified: 2024-02-07 17:50
    - 28.2K bytes
    - Viewed (0)
  5. guava-tests/test/com/google/common/math/MathBenchmarking.java

        return result;
      }
    
      /**
       * Generates a number in [0, 2^numBits) with an exponential distribution. The floor of the log2 of
       * the result is chosen uniformly at random in [0, numBits), and then the result is chosen in that
       * range uniformly at random. Zero is treated as having log2 == 0.
       */
      static BigInteger randomNonNegativeBigInteger(int numBits) {
        int digits = RANDOM_SOURCE.nextInt(numBits);
    Java
    - Registered: 2024-04-12 12:43
    - Last Modified: 2017-12-04 17:37
    - 4.1K bytes
    - Viewed (0)
  6. 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);
    Java
    - Registered: 2024-04-12 12:43
    - Last Modified: 2024-02-07 17:50
    - 28.1K bytes
    - Viewed (0)
  7. android/guava-tests/benchmark/com/google/common/math/DoubleMathBenchmark.java

          doubles[i] = randomDouble(Long.SIZE);
          factorials[i] = RANDOM_SOURCE.nextInt(100);
        }
      }
    
      @Benchmark
      long log2(int reps) {
        long tmp = 0;
        for (int i = 0; i < reps; i++) {
          int j = i & ARRAY_MASK;
          tmp += Double.doubleToRawLongBits(DoubleMath.log2(positiveDoubles[j]));
        }
        return tmp;
      }
    
      @Benchmark
      long factorial(int reps) {
        long tmp = 0;
    Java
    - Registered: 2024-04-12 12:43
    - Last Modified: 2017-12-04 17:37
    - 2.5K bytes
    - Viewed (0)
  8. guava-tests/benchmark/com/google/common/math/IntMathRoundingBenchmark.java

        }
      }
    
      @Param({"DOWN", "UP", "FLOOR", "CEILING", "HALF_EVEN", "HALF_UP", "HALF_DOWN"})
      RoundingMode mode;
    
      @Benchmark
      int log2(int reps) {
        int tmp = 0;
        for (int i = 0; i < reps; i++) {
          int j = i & ARRAY_MASK;
          tmp += IntMath.log2(positive[j], mode);
        }
        return tmp;
      }
    
      @Benchmark
      int log10(int reps) {
        int tmp = 0;
        for (int i = 0; i < reps; i++) {
    Java
    - Registered: 2024-04-12 12:43
    - Last Modified: 2017-12-04 17:37
    - 2.6K bytes
    - Viewed (0)
  9. guava-tests/benchmark/com/google/common/math/LongMathRoundingBenchmark.java

          nonzero[i] = randomNonZeroBigInteger(Long.SIZE - 2).longValue();
          longs[i] = RANDOM_SOURCE.nextLong();
        }
      }
    
      @Benchmark
      int log2(int reps) {
        int tmp = 0;
        for (int i = 0; i < reps; i++) {
          int j = i & ARRAY_MASK;
          tmp += LongMath.log2(positive[j], mode);
        }
        return tmp;
      }
    
      @Benchmark
      int log10(int reps) {
        int tmp = 0;
        for (int i = 0; i < reps; i++) {
    Java
    - Registered: 2024-04-12 12:43
    - Last Modified: 2017-12-04 17:37
    - 2.6K bytes
    - Viewed (0)
  10. 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).
    Java
    - Registered: 2024-04-12 12:43
    - Last Modified: 2024-02-07 17:50
    - 24.5K bytes
    - Viewed (0)
Back to top