List of usage examples for java.math BigInteger valueOf
private static BigInteger valueOf(int val[])
From source file:FactQuoter.java
/** The factorial() method, using BigIntegers cached in a ArrayList */ public static synchronized BigInteger factorial(int x) { if (x < 0) throw new IllegalArgumentException("x must be non-negative."); for (int size = table.size(); size <= x; size++) { BigInteger lastfact = (BigInteger) table.get(size - 1); BigInteger nextfact = lastfact.multiply(BigInteger.valueOf(size)); table.add(nextfact);/*w w w . ja va 2s . com*/ } return (BigInteger) table.get(x); }
From source file:eu.bittrade.libs.steemj.plugins.apis.condenser.models.ExtendedDynamicGlobalProperties.java
/** * This object is only used to wrap the JSON response in a POJO, so * therefore this class should not be instantiated. *//*from w ww.j av a2 s . c o m*/ private ExtendedDynamicGlobalProperties() { this.avarageBlockSize = UInteger.valueOf(0); this.currentReserveRatio = ULong.valueOf(1); this.maxVirtualBandwidth = BigInteger.valueOf(0); }
From source file:net.sf.jasperreports.data.cache.BigIntegerStore.java
private void reset() { this.rawStore.resetValues(); this.min = BigInteger.valueOf(Long.MAX_VALUE); this.max = BigInteger.valueOf(Long.MIN_VALUE); }
From source file:cherry.foundation.type.mybatis.SecureBigIntegerTypeHandlerTest.java
@Test public void testSaveAndLoad() { BigInteger plain = BigInteger.valueOf(random.nextLong()); ConversionTest record = new ConversionTest(); record.setSecBigint(SecureBigInteger.plainValueOf(plain)); int count = mapper.insert(record); assertThat(count, is(1));//from w w w .j av a2 s .com assertThat(record.getId(), is(not(0))); List<ConversionTest> list = mapper.selectAll(); assertThat(list.isEmpty(), is(false)); ConversionTest r = list.get(0); assertThat(r.getSecBigint().plain(), is(plain)); }
From source file:cherry.foundation.type.jdbc.JdbcSecureBigIntegerTest.java
@Test public void testSaveAndLoad() { BigInteger plain = BigInteger.valueOf(random.nextLong()); ConversionTest record = new ConversionTest(); record.setSecBigint(SecureBigInteger.plainValueOf(plain)); KeyHolder keyHolder = new GeneratedKeyHolder(); int count = jdbcDao.insert(record, keyHolder); assertThat(count, is(1));//from w w w . j av a2s . co m assertThat(keyHolder.getKey().intValue(), is(not(0))); List<ConversionTest> list = jdbcDao.selectAll(); assertThat(list.isEmpty(), is(false)); ConversionTest r = list.get(0); assertThat(r.getSecBigint().plain(), is(plain)); }
From source file:com.basho.riak.client.itest.ITestStats.java
@Test public void testDeserializer() throws IOException { NodeStats.UndefinedStatDeserializer usd = new NodeStats.UndefinedStatDeserializer(); SimpleModule module = new SimpleModule("UndefinedStatDeserializer", new Version(1, 0, 0, null, null, null)); module.addDeserializer(BigInteger.class, usd); String json = "{\"vnode_gets\":\"deprecated\",\"vnode_gets_total\":12345678}"; ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(module);/*from w w w.ja va 2s .c om*/ NodeStats stats = mapper.readValue(json, NodeStats.class); assertEquals(stats.vnodeGets(), BigInteger.ZERO); assertEquals(stats.vnodeGetsTotal(), BigInteger.valueOf(12345678)); }
From source file:it.gualtierotesta.gdocx.GTr.java
/** * Set row height with EXACT rule//from ww w . j a va 2s . co m * * @param lHeight height of the row * @return same GTr instance */ @Nonnull public GTr height(final long lHeight) { Validate.isTrue(0L < lHeight, "Height value not valid"); final CTHeight cth = FACTORY.createCTHeight(); cth.setVal(BigInteger.valueOf(lHeight)); cth.setHRule(STHeightRule.EXACT); trPr.getCnfStyleOrDivIdOrGridBefore().add(FACTORY.createCTTrPrBaseTrHeight(cth)); return this; }
From source file:Main.java
/** * Subtract one positive Duration from another, larger positive Duration. * @param d1 The larger positive duration * @param d2 The smaller positive duration * @return The difference//from w w w.ja va 2 s . c o m */ private static Duration subtractSmallerPositiveDurationFromLargerPositiveDuration(Duration d1, Duration d2) { BigDecimal s1 = fractionalSeconds(d1); BigDecimal s2 = fractionalSeconds(d2); BigDecimal extraSeconds = s1.subtract(s2); Duration strip1 = stripFractionalSeconds(d1); Duration strip2 = stripFractionalSeconds(d2); Duration stripResult = strip1.subtract(strip2); if (extraSeconds.compareTo(BigDecimal.ZERO) < 0) { stripResult = stripResult.subtract(DURATION_1_SECOND); extraSeconds = extraSeconds.add(BigDecimal.ONE); } BigDecimal properSeconds = BigDecimal.valueOf(stripResult.getSeconds()).add(extraSeconds); return FACTORY.newDuration(true, BigInteger.valueOf(stripResult.getYears()), BigInteger.valueOf(stripResult.getMonths()), BigInteger.valueOf(stripResult.getDays()), BigInteger.valueOf(stripResult.getHours()), BigInteger.valueOf(stripResult.getMinutes()), properSeconds); }
From source file:ID.java
public static String getHexString(byte[] bytes) { // This method cannot change even if it's wrong. BigInteger bigInteger = BigInteger.ZERO; int shift = 0; for (int i = bytes.length; --i >= 0;) { BigInteger contrib = BigInteger.valueOf(bytes[i] & 0xFF); contrib = contrib.shiftLeft(shift); bigInteger = bigInteger.add(contrib); shift += 8;// w w w. j ava 2 s. c o m } return bigInteger.toString(16).toUpperCase(); }
From source file:it.gualtierotesta.gdocx.GFactory.java
/** * Build a CT border/*w w w.j a va 2s .co m*/ * * @param lSize width of the border in eighths of a point (min 2, max 96) * @param eBorderLine type of the border line (enum) * @param sColor color of the border line in RRGGBB format (es. FFFF00). It can be null if no border line * @param lSpace Specifies the spacing offset. Values are specified in points (1/72nd of an inch). it can be * null * @return same GTc instance */ public static CTBorder buildBorder(final long lSize, @Nonnull final STBorder eBorderLine, @CheckForNull final String sColor, @CheckForNull final Long lSpace) { Validate.isTrue(2L <= lSize && lSize <= 96, "Size value not valid"); Validate.notNull(eBorderLine, "Border Line not valid"); final CTBorder ctBorder = FACTORY.createCTBorder(); ctBorder.setVal(eBorderLine); if (STBorder.NIL != eBorderLine && STBorder.NONE != eBorderLine) { if (null != sColor) { ctBorder.setColor(sColor); } if (null != lSpace) { ctBorder.setSpace(BigInteger.valueOf(lSpace)); } ctBorder.setSz(BigInteger.valueOf(lSize)); } return ctBorder; }