當前位置: 首頁>>代碼示例>>Java>>正文


Java LongMath.checkedMultiply方法代碼示例

本文整理匯總了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);
}
 
開發者ID:MGunlogson,項目名稱:CuckooFilter4J,代碼行數:23,代碼來源:FilterTable.java

示例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;
  }
}
 
開發者ID:sander120786,項目名稱:guava-libraries,代碼行數:10,代碼來源:ApacheBenchmark.java

示例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;
  }
}
 
開發者ID:google,項目名稱:error-prone,代碼行數:29,代碼來源:ConstantOverflow.java

示例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);
}
 
開發者ID:pfichtner,項目名稱:jrunalyzer,代碼行數:11,代碼來源:DefaultSpeed.java

示例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;
}
 
開發者ID:creativechain,項目名稱:creacoinj,代碼行數:5,代碼來源:AbstractCoin.java

示例6: multiply

import com.google.common.math.LongMath; //導入方法依賴的package包/類
public Coin multiply(final long factor) {
    return new Coin(LongMath.checkedMultiply(this.value, factor));
}
 
開發者ID:creativechain,項目名稱:creacoinj,代碼行數:4,代碼來源:Coin.java

示例7: multiply

import com.google.common.math.LongMath; //導入方法依賴的package包/類
public Fiat multiply(final long factor) {
    return new Fiat(currencyCode, LongMath.checkedMultiply(this.value, factor));
}
 
開發者ID:guodroid,項目名稱:okwallet,代碼行數:4,代碼來源:Fiat.java

示例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));
}
 
開發者ID:filipnyquist,項目名稱:lbry-android,代碼行數:4,代碼來源:Value.java

示例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;
}
 
開發者ID:jaytaylor,項目名稱:sql-layer,代碼行數:7,代碼來源:AkInterval.java

示例10: multiply

import com.google.common.math.LongMath; //導入方法依賴的package包/類
public Altcoin multiply(final long factor) {
    return new Altcoin(currencyCode, LongMath.checkedMultiply(this.value, factor));
}
 
開發者ID:bisq-network,項目名稱:exchange,代碼行數:4,代碼來源:Altcoin.java


注:本文中的com.google.common.math.LongMath.checkedMultiply方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。