Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 10 for checkedAdd (0.21 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) {
    Java
    - Registered: Fri May 03 12:43:13 GMT 2024
    - Last Modified: Mon Dec 04 17:37:03 GMT 2017
    - 6.9K bytes
    - Viewed (0)
  2. 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) {
    Java
    - Registered: Fri Apr 19 12:43:09 GMT 2024
    - Last Modified: Mon Dec 04 17:37:03 GMT 2017
    - 6.9K bytes
    - Viewed (0)
  3. android/guava/src/com/google/common/math/IntMath.java

       *
       * @throws ArithmeticException if {@code a + b} overflows in signed {@code int} arithmetic
       */
      public static int checkedAdd(int a, int b) {
        long result = (long) a + b;
        checkNoOverflow(result == (int) result, "checkedAdd", a, b);
        return (int) result;
      }
    
      /**
       * Returns the difference of {@code a} and {@code b}, provided it does not overflow.
       *
    Java
    - Registered: Fri Apr 26 12:43:10 GMT 2024
    - Last Modified: Wed Feb 07 17:50:39 GMT 2024
    - 23.5K bytes
    - Viewed (0)
  4. 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);
              }
            }
          }
        }
      }
    
    Java
    - Registered: Fri Apr 12 12:43:09 GMT 2024
    - Last Modified: Mon Mar 04 20:15:57 GMT 2024
    - 32.5K bytes
    - Viewed (0)
  5. android/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);
              }
            }
          }
        }
      }
    
    Java
    - Registered: Fri May 03 12:43:13 GMT 2024
    - Last Modified: Mon Mar 04 20:15:57 GMT 2024
    - 32.5K 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
    Java
    - Registered: Fri May 03 12:43:13 GMT 2024
    - Last Modified: Wed Feb 07 17:50:39 GMT 2024
    - 24.5K bytes
    - Viewed (0)
  7. 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;
                }
    Java
    - Registered: Fri May 03 12:43:13 GMT 2024
    - Last Modified: Thu Feb 22 21:19:52 GMT 2024
    - 20.9K bytes
    - Viewed (0)
  8. 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;
                }
    Java
    - Registered: Fri Apr 05 12:43:09 GMT 2024
    - Last Modified: Thu Feb 22 21:19:52 GMT 2024
    - 20.9K bytes
    - Viewed (0)
  9. 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
    Java
    - Registered: Fri Apr 12 12:43:09 GMT 2024
    - Last Modified: Wed Feb 07 17:50:39 GMT 2024
    - 24.5K bytes
    - Viewed (0)
  10. android/guava/src/com/google/common/math/LongMath.java

       * @throws ArithmeticException if {@code a + b} overflows in signed {@code long} arithmetic
       */
      @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.
       *
    Java
    - Registered: Fri Apr 26 12:43:10 GMT 2024
    - Last Modified: Wed Feb 07 17:50:39 GMT 2024
    - 44.6K bytes
    - Viewed (0)
Back to top