List of usage examples for com.google.common.math IntMath checkedSubtract
public static int checkedSubtract(int a, int b)
From source file:com.wandrell.tabletop.stats.controller.DefaultValueController.java
@Override public final void decreaseValue() { Integer value;/*from www . jav a 2 s . co m*/ if (getValue() != null) { try { value = IntMath.checkedSubtract(getValue().getValue(), getStep()); } catch (final ArithmeticException exception) { value = Integer.MIN_VALUE; } if (value >= getLowerLimit()) { getValue().setValue(value); } } }
From source file:com.wandrell.tabletop.stats.controller.DefaultValueController.java
@Override public final Boolean isAbleToDecrease() { final Boolean result; Integer value;/*from w w w .j a v a2s . com*/ if (getValue() == null) { result = false; } else { try { value = IntMath.checkedSubtract(getValue().getValue(), getStep()); } catch (final ArithmeticException exception) { value = Integer.MIN_VALUE; } result = (value >= getLowerLimit()); } return result; }
From source file:com.google.errorprone.bugpatterns.ConstantOverflow.java
static Integer binop(Kind kind, int lhs, int rhs) { switch (kind) { case MULTIPLY: return IntMath.checkedMultiply(lhs, rhs); case DIVIDE:/*from w ww . j av a 2 s . c o m*/ return lhs / rhs; case REMAINDER: return lhs % rhs; case PLUS: return IntMath.checkedAdd(lhs, rhs); case MINUS: return IntMath.checkedSubtract(lhs, rhs); case LEFT_SHIFT: return lhs << rhs; case RIGHT_SHIFT: return lhs >> rhs; case UNSIGNED_RIGHT_SHIFT: return lhs >>> rhs; case AND: return lhs & rhs; case XOR: return lhs ^ rhs; case OR: return lhs | rhs; default: return null; } }
From source file:com.tkmtwo.timex.WallClock.java
/** * Returns a copy of this <code>WallClock</code> minus * the specified number of seconds./*from w ww. ja v a 2 s. c o m*/ * <p> * * @param secs an <code>int</code> representing the seconds * @return a <code>WallClock</code> value */ public WallClock minus(int secs) { return valueOf(IntMath.checkedSubtract(getSeconds(), secs)); }
From source file:com.tkmtwo.timex.WallClock.java
@Override public int compareTo(WallClock wc) { if (wc == null) { return 0; }/* ww w .j av a2 s. com*/ return IntMath.checkedSubtract(getSeconds(), wc.getSeconds()); }