public AlternativeJdkIdGenerator() { SecureRandom secureRandom = new SecureRandom(); byte[] seed = new byte[8]; secureRandom.nextBytes(seed); this.random = new Random(new BigInteger(seed).longValue()); }
private byte getRealV(BigInteger bv) { if (bv.bitLength() > 31) return 0; // chainId is limited to 31 bits, longer are not valid for now long v = bv.longValue(); if (v == LOWER_REAL_V || v == (LOWER_REAL_V + 1)) return (byte) v; byte realV = LOWER_REAL_V; int inc = 0; if ((int) v % 2 == 0) inc = 1; return (byte) (realV + inc); }
@Override protected long vertexCount() { BigInteger vertexCount = BigInteger.ONE; for (Dimension dimension : dimensions) { vertexCount = vertexCount.multiply(BigInteger.valueOf(dimension.size)); } if (vertexCount.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) > 0) { throw new ProgramParametrizationException("Number of vertices in grid graph '" + vertexCount + "' is greater than Long.MAX_VALUE."); } return vertexCount.longValue(); }
BigInteger n = new BigInteger(_cleanedTextValue); if (len == 19 && n.bitLength() <= 63) { _numberLong = n.longValue(); _numTypesValid = NR_LONG; return;
BigInteger txGasLimit = new BigInteger(1, tx.getGasLimit()); BigInteger curBlockGasLimit = new BigInteger(1, currentBlock.getGasLimit()); boolean cumulativeGasReached = txGasLimit.add(BigInteger.valueOf(gasUsedInTheBlock)).compareTo(curBlockGasLimit) > 0; if (cumulativeGasReached) { execError(String.format("Too much gas used in this block: Require: %s Got: %s", new BigInteger(1, currentBlock.getGasLimit()).longValue() - toBI(tx.getGasLimit()).longValue(), toBI(tx.getGasLimit()).longValue())); if (txGasLimit.compareTo(BigInteger.valueOf(basicTxCost)) < 0) {
private static long parseBinaryBigInteger(final byte[] buffer, final int offset, final int length, final boolean negative) { final byte[] remainder = new byte[length - 1]; System.arraycopy(buffer, offset + 1, remainder, 0, length - 1); BigInteger val = new BigInteger(remainder); if (negative) { // 2's complement val = val.add(BigInteger.valueOf(-1)).not(); } if (val.bitLength() > 63) { throw new IllegalArgumentException(String.format( "At offset %d, %d byte binary number exceeds maximum signed long value", offset, length)); } return negative ? -val.longValue() : val.longValue(); }
@Override public Long fromJson(JsonReader reader) throws IOException { BigInteger bigInteger = new BigInteger(reader.nextString()); return bigInteger.compareTo(maxLong) > 0 ? bigInteger.subtract(power64).longValue() : bigInteger.longValue(); }
BigInteger max = BigInteger.valueOf(2).pow(255); byte[] target = BigIntegers.asUnsignedByteArray(32, max.divide(new BigInteger(1, difficulty))); (new BigInteger(1, newBlock.getGasLimit()).longValue() * (1024 - 1) + (newBlock.getGasUsed() * 6 / 5)) / 1024); newBlock.getHeader().setGasLimit(BigInteger.valueOf(newGasLimit).toByteArray()); System.out.println("mining: " + new BigInteger(1, testNonce));
if(scaledDivisor.bitLength() < 63) { // 63 in order to avoid out of long after *2 long rem = remainder.longValue(); long divisor = scaledDivisor.longValue(); compRem = longCompareTo(Math.abs(rem) * 2,Math.abs(divisor)); compRem = remainder.abs().shiftLeftOneBit().compareTo(scaledDivisor.abs()); compRem = roundingBehavior(quotient.testBit(0) ? 1 : 0, sign * (5 + compRem), roundingMode); if(quotient.bitLength() < 63) { return valueOf(quotient.longValue() + compRem,scale); quotient = quotient.add(BigInteger.valueOf(compRem)); return new BigDecimal(quotient, scale);
public long getCumulativeGasLong() { return new BigInteger(1, cumulativeGas).longValue(); }
BigInteger bigValue = new BigInteger(numberText, radix); if (negative) { bigValue = bigValue.negate(); if (bigValue.bitLength() > 31) { throw new NumberFormatException( "Number out of range for 32-bit signed integer: " + text); if (bigValue.bitLength() > 32) { throw new NumberFormatException( "Number out of range for 32-bit unsigned integer: " + text); if (bigValue.bitLength() > 63) { throw new NumberFormatException( "Number out of range for 64-bit signed integer: " + text); result = bigValue.longValue();
private static LocalDateTime nanosToLocalDateTimeUTC(long epocNanos) { // the pg plugin stores date/time info as microseconds since epoch BigInteger epochMicrosBigInt = BigInteger.valueOf(epocNanos); BigInteger[] secondsAndNanos = epochMicrosBigInt.divideAndRemainder(BigInteger.valueOf(TimeUnit.SECONDS.toNanos(1))); return LocalDateTime.ofInstant(Instant.ofEpochSecond(secondsAndNanos[0].longValue(), secondsAndNanos[1].longValue()), ZoneOffset.UTC); }
private static long parseBinaryBigInteger(final byte[] buffer, final int offset, final int length, final boolean negative) { final byte[] remainder = new byte[length - 1]; System.arraycopy(buffer, offset + 1, remainder, 0, length - 1); BigInteger val = new BigInteger(remainder); if (negative) { // 2's complement val = val.add(BigInteger.valueOf(-1)).not(); } if (val.bitLength() > 63) { throw new IllegalArgumentException("At offset " + offset + ", " + length + " byte binary number" + " exceeds maximum signed long" + " value"); } return negative ? -val.longValue() : val.longValue(); }
/** * Get exactly number value and type. * * @param value string to be converted * @param radix radix * @return exactly number value and type */ public static Number getExactlyNumber(final String value, final int radix) { BigInteger result = new BigInteger(value, radix); if (result.compareTo(new BigInteger(String.valueOf(Integer.MIN_VALUE))) >= 0 && result.compareTo(new BigInteger(String.valueOf(Integer.MAX_VALUE))) <= 0) { return result.intValue(); } if (result.compareTo(new BigInteger(String.valueOf(Long.MIN_VALUE))) >= 0 && result.compareTo(new BigInteger(String.valueOf(Long.MAX_VALUE))) <= 0) { return result.longValue(); } return result; } }
compRem = quotAndRem[1].shiftLeftOneBit().compareTo(powerOfTen); BigInteger.valueOf((compRem * (compRem + 3)) / 2 + 1)); exponent -= 2; discardedSize = mantissa.bitLength() - 54; if (discardedSize > 0) {// (n > 54) bits = mantissa.shiftRight(discardedSize).longValue(); tempBits = bits; bits = mantissa.longValue() << -discardedSize; tempBits = bits;