Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 7 of 7 for checkedAdd (0.13 sec)

  1. android/guava-tests/benchmark/com/google/common/math/ApacheBenchmark.java

          public boolean noAddOverflow(int a, int b) {
            try {
              int unused = IntMath.checkedAdd(a, b);
              return true;
            } catch (ArithmeticException e) {
              return false;
            }
          }
    
          @Override
          public boolean noAddOverflow(long a, long b) {
            try {
              long unused = LongMath.checkedAdd(a, b);
              return true;
            } catch (ArithmeticException e) {
    Registered: Fri Nov 01 12:43:10 UTC 2024
    - Last Modified: Mon Dec 04 17:37:03 UTC 2017
    - 6.9K bytes
    - Viewed (0)
  2. guava-tests/test/com/google/common/math/LongMathTest.java

            boolean expectedSuccess = fitsInLong(expectedResult);
            try {
              assertEquals(a + b, LongMath.checkedAdd(a, b));
              assertTrue(expectedSuccess);
            } catch (ArithmeticException e) {
              if (expectedSuccess) {
                failFormat(
                    "expected checkedAdd(%s, %s) = %s; got ArithmeticException", a, b, expectedResult);
              }
            }
          }
        }
      }
    
    Registered: Fri Nov 01 12:43:10 UTC 2024
    - Last Modified: Fri Oct 18 15:00:32 UTC 2024
    - 30.6K bytes
    - Viewed (0)
  3. guava-tests/test/com/google/common/math/IntMathTest.java

          for (int b : ALL_INTEGER_CANDIDATES) {
            BigInteger expectedResult = valueOf(a).add(valueOf(b));
            boolean expectedSuccess = fitsInInt(expectedResult);
            try {
              assertEquals(a + b, IntMath.checkedAdd(a, b));
              assertTrue(expectedSuccess);
            } catch (ArithmeticException e) {
              assertFalse(expectedSuccess);
            }
          }
        }
      }
    
      @AndroidIncompatible // slow
    Registered: Fri Nov 01 12:43:10 UTC 2024
    - Last Modified: Sat Oct 19 00:26:48 UTC 2024
    - 23.1K bytes
    - Viewed (0)
  4. android/guava/src/com/google/common/collect/ConcurrentHashMultiset.java

          }
    
          while (true) {
            int oldValue = existingCounter.get();
            if (oldValue != 0) {
              try {
                int newValue = IntMath.checkedAdd(oldValue, occurrences);
                if (existingCounter.compareAndSet(oldValue, newValue)) {
                  // newValue can't == 0, so no need to check & remove
                  return oldValue;
                }
    Registered: Fri Nov 01 12:43:10 UTC 2024
    - Last Modified: Wed Oct 30 16:15:19 UTC 2024
    - 21.1K bytes
    - Viewed (0)
  5. guava/src/com/google/common/math/LongMath.java

       */
      // Whenever both tests are cheap and functional, it's faster to use &, | instead of &&, ||
      @SuppressWarnings("ShortCircuitBoolean")
      public static long checkedAdd(long a, long b) {
        long result = a + b;
        checkNoOverflow((a ^ b) < 0 | (a ^ result) >= 0, "checkedAdd", a, b);
        return result;
      }
    
      /**
       * Returns the difference of {@code a} and {@code b}, provided it does not overflow.
       *
    Registered: Fri Nov 01 12:43:10 UTC 2024
    - Last Modified: Wed Oct 09 16:39:37 UTC 2024
    - 45.2K bytes
    - Viewed (0)
  6. android/guava-tests/test/com/google/common/math/IntMathTest.java

          for (int b : ALL_INTEGER_CANDIDATES) {
            BigInteger expectedResult = valueOf(a).add(valueOf(b));
            boolean expectedSuccess = fitsInInt(expectedResult);
            try {
              assertEquals(a + b, IntMath.checkedAdd(a, b));
              assertTrue(expectedSuccess);
            } catch (ArithmeticException e) {
              assertFalse(expectedSuccess);
            }
          }
        }
      }
    
      @AndroidIncompatible // slow
    Registered: Fri Nov 01 12:43:10 UTC 2024
    - Last Modified: Sat Oct 19 00:26:48 UTC 2024
    - 23.1K bytes
    - Viewed (0)
  7. android/guava/src/com/google/common/math/LongMath.java

       */
      // Whenever both tests are cheap and functional, it's faster to use &, | instead of &&, ||
      @SuppressWarnings("ShortCircuitBoolean")
      public static long checkedAdd(long a, long b) {
        long result = a + b;
        checkNoOverflow((a ^ b) < 0 | (a ^ result) >= 0, "checkedAdd", a, b);
        return result;
      }
    
      /**
       * Returns the difference of {@code a} and {@code b}, provided it does not overflow.
       *
    Registered: Fri Nov 01 12:43:10 UTC 2024
    - Last Modified: Wed Oct 09 16:39:37 UTC 2024
    - 45.2K bytes
    - Viewed (0)
Back to top