本文整理汇总了Java中java.math.BigInteger.ZERO属性的典型用法代码示例。如果您正苦于以下问题:Java BigInteger.ZERO属性的具体用法?Java BigInteger.ZERO怎么用?Java BigInteger.ZERO使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.math.BigInteger
的用法示例。
在下文中一共展示了BigInteger.ZERO属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: valInt
@Override
public BigInteger valInt() {
long index = 0;
String s = args.get(0).valStr();
String source = args.get(1).valStr();
if (args.get(0).isNull() || args.get(1).isNull()) {
this.nullValue = true;
return BigInteger.ZERO;
}
if (source.isEmpty())
return BigInteger.ZERO;
String[] ss = source.split(",");
for (int i = 0; i < ss.length; ++i) {
if (ss[i].equals(s)) {
index = i + 1;
break;
}
}
return BigInteger.valueOf(index);
}
示例2: set
/** Compute a coefficient in the internal table.
* @param n the zero-based index of the coefficient. n=0 for the E_0 term.
* @author Richard J. Mathar
*/
protected void set(final int n)
{
while ( n >= a.size())
{
BigInteger val = BigInteger.ZERO ;
boolean sigPos = true;
int thisn = a.size() ;
for(int i= thisn-1 ; i > 0 ; i--)
{
BigInteger f = new BigInteger(""+ a.elementAt(i).toString() ) ;
f = f.multiply( BigIntegerMath.binomial(2*thisn,2*i) );
if ( sigPos )
val = val.add(f) ;
else
val = val.subtract(f) ;
sigPos = ! sigPos ;
}
if ( thisn % 2 ==0 )
val = val.subtract(BigInteger.ONE) ;
else
val = val.add(BigInteger.ONE) ;
a.add(val) ;
}
}
示例3: sizeOfDirectoryAsBigInteger
/**
* Counts the size of a directory recursively (sum of the length of all files).
*
* @param directory directory to inspect, must not be {@code null}
* @return size of directory in bytes, 0 if directory is security restricted.
* @throws NullPointerException if the directory is {@code null}
* @since 2.4
*/
public static BigInteger sizeOfDirectoryAsBigInteger(File directory) {
checkDirectory(directory);
final File[] files = directory.listFiles();
if (files == null) { // null if security restricted
return BigInteger.ZERO;
}
BigInteger size = BigInteger.ZERO;
for (final File file : files) {
try {
if (!isSymlink(file)) {
size = size.add(BigInteger.valueOf(sizeOf(file)));
}
} catch (IOException ioe) {
// Ignore exceptions caught when asking if a File is a symlink.
}
}
return size;
}
示例4: defineTypeSize
private void defineTypeSize(String macroName, int typeWidth, String valSuffix,
boolean isSigned, StringBuilder buf)
{
BigInteger maxVal;
if (isSigned)
{
BigInteger one = BigInteger.ONE;
maxVal = one.shiftLeft(typeWidth - 1).subtract(one);
}
else
{
BigInteger zero = BigInteger.ZERO;
maxVal = zero.not().shiftRight(64 - typeWidth);
}
defineBuiltinMacro(buf, macroName + "=" + maxVal.toString(10) + valSuffix);
}
示例5: createAccount
@Override
public synchronized AccountState createAccount(final byte[] addr) {
AccountState accountState = new AccountState(BigInteger.ZERO, BigInteger.ZERO);
updateAccountState(addr, accountState);
updateContractDetails(addr, new ContractDetailsImpl(config));
return accountState;
}
示例6: getBalances
/**
* This may take a while, make sure you obey the limits of the api provider
*/
public BigInteger getBalances(List<String> contract) throws IOException {
BigInteger result = BigInteger.ZERO;
List<List<String>> part = Lists.partition(contract, 20);
for(List<String> p:part) {
result = result.add(get20Balances(p));
}
return result;
//TODO:caching!
}
示例7: valInt
@Override
public BigInteger valInt() {
LongPtr year = new LongPtr(0);
long week;
MySQLTime ltime = new MySQLTime();
if (getArg0Date(ltime, MyTime.TIME_NO_ZERO_DATE))
return BigInteger.ZERO;
week = MyTime.calcWeek(ltime, (MyTime.weekMode(args.size() > 1 ? args.get(1).valInt().intValue() : 0) | MyTime.WEEK_YEAR), year);
return BigInteger.valueOf(week + year.get() * 100);
}
示例8: testValueOfBigInteger
public void testValueOfBigInteger() {
BigInteger min = BigInteger.ZERO;
BigInteger max = UnsignedLong.MAX_VALUE.bigIntegerValue();
for (BigInteger big : TEST_BIG_INTEGERS) {
boolean expectSuccess =
big.compareTo(min) >= 0 && big.compareTo(max) <= 0;
try {
assertEquals(big, UnsignedLong.valueOf(big).bigIntegerValue());
assertTrue(expectSuccess);
} catch (IllegalArgumentException e) {
assertFalse(expectSuccess);
}
}
}
示例9: multiply
public static Multiplicity multiply( Multiplicity lhs, Multiplicity rhs ) {
BigInteger min = lhs.min.multiply(rhs.min);
BigInteger max;
if (isZero(lhs.max) || isZero(rhs.max))
max = BigInteger.ZERO;
else
if (lhs.max==null || rhs.max==null)
max = null;
else
max = lhs.max.multiply(rhs.max);
return create(min,max);
}
示例10: cmpDouble
private BigInteger cmpDouble() {
double value = args.get(0).valReal().doubleValue();
double a = args.get(1).valReal().doubleValue();
double b = args.get(2).valReal().doubleValue();
if (!args.get(1).isNull() && !args.get(2).isNull()) {
return (value >= a && value <= b) != negated ? BigInteger.ONE : BigInteger.ZERO;
}
return varNullValue(value, a, b);
}
示例11: valInt
@Override
public BigInteger valInt() {
String s = args.get(0).valStr();
if (args.get(0).isNull()) {
this.nullValue = true;
return BigInteger.ZERO;
} else {
if (s.length() == 0) {
return BigInteger.ZERO;
} else {
return BigInteger.valueOf((int) s.charAt(0));
}
}
}
示例12: dumpState
@SuppressWarnings("uncheked")
public static void dumpState(ObjectNode statesNode, String address, AccountState state, ContractDetails details) {
List<DataWord> storageKeys = new ArrayList<>(details.getStorage().keySet());
Collections.sort(storageKeys);
ObjectNode account = statesNode.objectNode();
ObjectNode storage = statesNode.objectNode();
for (DataWord key : storageKeys) {
storage.put("0x" + Hex.toHexString(key.getData()),
"0x" + Hex.toHexString(details.getStorage().get(key).getNoLeadZeroesData()));
}
if (state == null)
state = new AccountState(SystemProperties.getDefault().getBlockchainConfig().getCommonConstants().getInitialNonce(),
BigInteger.ZERO);
account.put("balance", state.getBalance() == null ? "0" : state.getBalance().toString());
// account.put("codeHash", details.getCodeHash() == null ? "0x" : "0x" + Hex.toHexString(details.getCodeHash()));
account.put("code", details.getCode() == null ? "0x" : "0x" + Hex.toHexString(details.getCode()));
account.put("nonce", state.getNonce() == null ? "0" : state.getNonce().toString());
account.set("storage", storage);
account.put("storage_root", state.getStateRoot() == null ? "" : Hex.toHexString(state.getStateRoot()));
statesNode.set(address, account);
}
示例13: os2i
/** Convierte un Octet String de ASN.1 en un entero
* (según <i>BSI TR 03111</i> Sección 3.1.2).
* @param Octet String de ASN.1.
* @param offset posición de inicio-
* @param length longitud del Octet String.
* @return Entero (siempre positivo). */
private static BigInteger os2i(final byte[] bytes, final int offset, final int length) {
if (bytes == null) {
throw new IllegalArgumentException("El Octet String no puede ser nulo"); //$NON-NLS-1$
}
BigInteger result = BigInteger.ZERO;
final BigInteger base = BigInteger.valueOf(256);
for (int i = offset; i < offset + length; i++) {
result = result.multiply(base);
result = result.add(BigInteger.valueOf(bytes[i] & 0xFF));
}
return result;
}
示例14: InterruptedExecutionBlockResult
public InterruptedExecutionBlockResult() {
super(Collections.emptyList(), Collections.emptyList(), null, 0, BigInteger.ZERO);
}
示例15: integerToBigInteger
private static BigInteger integerToBigInteger(ByteBuffer encoded) {
if (!encoded.hasRemaining()) {
return BigInteger.ZERO;
}
return new BigInteger(ByteBufferUtils.toByteArray(encoded));
}