本文整理汇总了Java中java.math.BigInteger.intValueExact方法的典型用法代码示例。如果您正苦于以下问题:Java BigInteger.intValueExact方法的具体用法?Java BigInteger.intValueExact怎么用?Java BigInteger.intValueExact使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.math.BigInteger
的用法示例。
在下文中一共展示了BigInteger.intValueExact方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setLockWhitelistDisableBlockDelay
import java.math.BigInteger; //导入方法依赖的package包/类
/**
* Sets a delay in the BTC best chain to disable lock whitelist
* @param tx current RSK transaction
* @param disableBlockDelayBI block since current BTC best chain height to disable lock whitelist
* @return 1 if it was successful, -1 if a delay was already set, -2 if disableBlockDelay contains an invalid value
*/
public Integer setLockWhitelistDisableBlockDelay(Transaction tx, BigInteger disableBlockDelayBI) {
if (!isLockWhitelistChangeAuthorized(tx)) {
return LOCK_WHITELIST_GENERIC_ERROR_CODE;
}
LockWhitelist lockWhitelist = provider.getLockWhitelist();
if (lockWhitelist.isDisableBlockSet()) {
return -1;
}
int disableBlockDelay = disableBlockDelayBI.intValueExact();
int bestChainHeight = btcBlockChain.getBestChainHeight();
if (bestChainHeight < 0 || Integer.MAX_VALUE - disableBlockDelay < bestChainHeight) {
return -2;
}
lockWhitelist.setDisableBlockHeight(bestChainHeight + disableBlockDelay);
return 1;
}
示例2: integerToInt
import java.math.BigInteger; //导入方法依赖的package包/类
private static int integerToInt(ByteBuffer encoded) throws Asn1DecodingException {
BigInteger value = integerToBigInteger(encoded);
try {
return value.intValueExact();
} catch (ArithmeticException e) {
throw new Asn1DecodingException(
String.format("INTEGER cannot be represented as int: %1$d (0x%1$x)", value), e);
}
}
示例3: parseInt
import java.math.BigInteger; //导入方法依赖的package包/类
private int parseInt(byte[] nrBytes) {
if (nrBytes == null) return 0;
BigInteger b = BigIntegers.fromUnsignedByteArray(nrBytes);
return b.intValueExact();
}