List of usage examples for com.google.common.math LongMath pow
@GwtIncompatible("TODO") public static long pow(long b, int k)
From source file:edu.mit.streamjit.util.affinity.NullAffinityStrategy.java
@Override public long getMaximalAffinityMask() { return LongMath.pow(2, Runtime.getRuntime().availableProcessors()) - 1; }
From source file:io.v.todos.persistence.syncbase.IdGenerator.java
/** * @param alphabet the alphabet of legal characters for IDs generated by this generator * @param perturb whether or not to perturb generated IDs by a random perturbation to avoid * collisions in distributed key generation. Pass {@code false} if this generator * is used to generate a sort key that is a secondary key where ordering * conflicts can be deterministically resolved by the primary key. This setting * only applies to the {@code generate...} methods. *//* w w w. jav a 2s. co m*/ public IdGenerator(IdAlphabet alphabet, boolean perturb) { mAlphabet = alphabet; mPerturb = perturb; // Find the maximum number of digits we'd need to encode an unsigned long if the radix were // uniform for the entire string. // ceil(log_RADIX(Long.MAX + 1)) mLongUniformRadixLength = (int) Math.ceil(LOG_LONG / Math.log(alphabet.radix())); mMostSignificantUnit = LongMath.pow(alphabet.radix(), mLongUniformRadixLength - 1); mMaxSafeMostSignificantDigit = (int) (Long.MAX_VALUE / mMostSignificantUnit); mMaxSafeMostSignificantValue = mMaxSafeMostSignificantDigit * mMostSignificantUnit; // The first character may have additional restrictions, so we have less chars to work with // for the first digit. If we still have enough digits, we'll proceed and just use a special // mapping for the leading digit. Otherwise, we'll pad by a leading zero, thus making the // remaining encoding the common case. // So, what most-significant digit do we need to encode the max unsigned value? PartialDivisionResult div = transformToSignedDivision(-1); int maxMostSignficantDigit = div.partialMostSignificantDigit + (int) (div.partialRemainder / mMostSignificantUnit); mLongEncodedLength = maxMostSignficantDigit < alphabet.leadingRadix() ? mLongUniformRadixLength : mLongUniformRadixLength + 1; }
From source file:org.apache.james.util.Size.java
public long asBytes() { switch (unit) { case G:/*from w ww . ja va2 s. c om*/ return value * LongMath.pow(base, 3); case M: return value * LongMath.pow(base, 2); case K: return value * LongMath.pow(base, 1); default: return value; } }
From source file:com.matthewmitchell.peercoinj.shapeshift.ShapeShiftMonetary.java
private BigInteger getBigIntegerOne() { return BigInteger.valueOf(LongMath.pow(10, smallestUnitExponent)); }
From source file:org.ethereum.datasource.QuotientFilter.java
static int bitsForNumElementsWithLoadFactor(long numElements) { if (numElements == 0) { return 1; }/*w w w. ja v a2s . c o m*/ int candidateBits = Long.bitCount(numElements) == 1 ? Math.max(1, Long.numberOfTrailingZeros(numElements)) : Long.numberOfTrailingZeros(Long.highestOneBit(numElements) << 1L); //May need an extra bit due to load factor if (((long) (LongMath.pow(2, candidateBits) * 0.75)) < numElements) { candidateBits++; } return candidateBits; }
From source file:io.bitsquare.gui.main.markets.charts.MarketsChartsViewModel.java
private void buildChartDataItems(List<Offer> sortedList, Offer.Direction direction, List<XYChart.Data> data) { data.clear();// w ww . j ava2 s. co m double accumulatedAmount = 0; for (Offer offer : sortedList) { Fiat priceAsFiat = offer.getPrice(); if (priceAsFiat != null) { double price = (double) priceAsFiat.value / LongMath.pow(10, priceAsFiat.smallestUnitExponent()); double amount = (double) offer.getAmount().value / LongMath.pow(10, offer.getAmount().smallestUnitExponent()); accumulatedAmount += amount; if (direction.equals(Offer.Direction.BUY)) data.add(0, new XYChart.Data(price, accumulatedAmount)); else data.add(new XYChart.Data(price, accumulatedAmount)); } } }
From source file:io.druid.math.expr.Expr.java
@Override protected final long evalLong(long left, long right) { return LongMath.pow(left, (int) right); }
From source file:org.apache.druid.math.expr.Expr.java
@Override protected final long evalLong(long left, long right) { return LongMath.pow(left, Ints.checkedCast(right)); }
From source file:io.bitsquare.gui.main.market.offerbook.OfferBookChartViewModel.java
private void buildChartAndTableEntries(List<Offer> sortedList, Offer.Direction direction, List<XYChart.Data> data, ObservableList<OfferListItem> offerTableList) { data.clear();/*from w w w. j a v a 2 s . c o m*/ double accumulatedAmount = 0; List<OfferListItem> offerTableListTemp = new ArrayList<>(); for (Offer offer : sortedList) { Fiat priceAsFiat = offer.getPrice(); if (priceAsFiat != null) { double amount = (double) offer.getAmount().value / LongMath.pow(10, offer.getAmount().smallestUnitExponent()); accumulatedAmount += amount; offerTableListTemp.add(new OfferListItem(offer, accumulatedAmount)); double price = (double) priceAsFiat.value / LongMath.pow(10, priceAsFiat.smallestUnitExponent()); if (CurrencyUtil.isCryptoCurrency(getCurrencyCode())) { price = price != 0 ? 1d / price : 0; if (direction.equals(Offer.Direction.SELL)) data.add(0, new XYChart.Data<>(price, accumulatedAmount)); else data.add(new XYChart.Data<>(price, accumulatedAmount)); } else { if (direction.equals(Offer.Direction.BUY)) data.add(0, new XYChart.Data<>(price, accumulatedAmount)); else data.add(new XYChart.Data<>(price, accumulatedAmount)); } } } offerTableList.setAll(offerTableListTemp); }