本文整理匯總了Java中com.google.common.math.LongMath.checkedMultiply方法的典型用法代碼示例。如果您正苦於以下問題:Java LongMath.checkedMultiply方法的具體用法?Java LongMath.checkedMultiply怎麽用?Java LongMath.checkedMultiply使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.common.math.LongMath
的用法示例。
在下文中一共展示了LongMath.checkedMultiply方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: create
import com.google.common.math.LongMath; //導入方法依賴的package包/類
/**
* Creates a FilterTable
*
* @param bitsPerTag
* number of bits needed for each tag
* @param numBuckets
* number of buckets in filter
* @return
*/
static FilterTable create(int bitsPerTag, long numBuckets) {
// why would this ever happen?
checkArgument(bitsPerTag < 48, "tagBits (%s) should be less than 48 bits", bitsPerTag);
// shorter fingerprints don't give us a good fill capacity
checkArgument(bitsPerTag > 4, "tagBits (%s) must be > 4", bitsPerTag);
checkArgument(numBuckets > 1, "numBuckets (%s) must be > 1", numBuckets);
// checked so our implementors don't get too.... "enthusiastic" with
// table size
long bitsPerBucket = IntMath.checkedMultiply(CuckooFilter.BUCKET_SIZE, bitsPerTag);
long bitSetSize = LongMath.checkedMultiply(bitsPerBucket, numBuckets);
LongBitSet memBlock = new LongBitSet(bitSetSize);
return new FilterTable(memBlock, bitsPerTag, numBuckets);
}
示例2: noMulOverflow
import com.google.common.math.LongMath; //導入方法依賴的package包/類
@Override
public boolean noMulOverflow(long a, long b) {
try {
LongMath.checkedMultiply(a, b);
return true;
} catch (ArithmeticException e) {
return false;
}
}
示例3: binop
import com.google.common.math.LongMath; //導入方法依賴的package包/類
static Long binop(Kind kind, long lhs, long rhs) {
switch (kind) {
case MULTIPLY:
return LongMath.checkedMultiply(lhs, rhs);
case DIVIDE:
return lhs / rhs;
case REMAINDER:
return lhs % rhs;
case PLUS:
return LongMath.checkedAdd(lhs, rhs);
case MINUS:
return LongMath.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;
}
}
示例4: convert
import com.google.common.math.LongMath; //導入方法依賴的package包/類
private DefaultSpeed convert(DistanceUnit distanceUnit, int time,
TimeUnit timeUnit) {
if (distanceUnit == this.distanceUnit && timeUnit == this.timeUnit) {
return this;
}
long longTime = LongMath.checkedMultiply(time, fix);
return new DefaultSpeed(distanceUnit.convert(
this.dPerT * this.timeUnit.convert(longTime, timeUnit),
this.distanceUnit) / fix, distanceUnit, timeUnit);
}
示例5: multiply
import com.google.common.math.LongMath; //導入方法依賴的package包/類
public <C extends AbstractCoin> C multiply(long factor) {
this.value = LongMath.checkedMultiply(this.value, factor);
return (C) this;
}
示例6: multiply
import com.google.common.math.LongMath; //導入方法依賴的package包/類
public Coin multiply(final long factor) {
return new Coin(LongMath.checkedMultiply(this.value, factor));
}
示例7: multiply
import com.google.common.math.LongMath; //導入方法依賴的package包/類
public Fiat multiply(final long factor) {
return new Fiat(currencyCode, LongMath.checkedMultiply(this.value, factor));
}
示例8: multiply
import com.google.common.math.LongMath; //導入方法依賴的package包/類
public Value multiply(final long factor) {
return new Value(this.type, LongMath.checkedMultiply(this.value, factor));
}
示例9: parseLong
import com.google.common.math.LongMath; //導入方法依賴的package包/類
@Override
protected long parseLong(long parsed, Boolean isYear) {
if (isYear)
parsed = LongMath.checkedMultiply(parsed, 12);
return parsed;
}
示例10: multiply
import com.google.common.math.LongMath; //導入方法依賴的package包/類
public Altcoin multiply(final long factor) {
return new Altcoin(currencyCode, LongMath.checkedMultiply(this.value, factor));
}