Example usage for com.google.common.math LongMath checkedPow

List of usage examples for com.google.common.math LongMath checkedPow

Introduction

In this page you can find the example usage for com.google.common.math LongMath checkedPow.

Prototype

@GwtIncompatible("TODO")
public static long checkedPow(long b, int k) 

Source Link

Document

Returns the b to the k th power, provided it does not overflow.

Usage

From source file:org.apache.asterix.runtime.evaluators.functions.NumericCaretDescriptor.java

@Override
protected long evaluateInteger(long lhs, long rhs) throws HyracksDataException {
    if (rhs > Integer.MAX_VALUE) {
        throw new ArithmeticException("Exponent cannot be larger than 2^31-1");
    }//  www .j a  v  a 2  s.  c o m
    return LongMath.checkedPow(lhs, (int) rhs);
}

From source file:com.qubole.quark.planner.AggStarRule.java

String bitSetToString(ImmutableBitSet bits) {
    long result = 0;
    for (Integer i : bits) {
        result += LongMath.checkedPow(2, i);
    }/*from   w ww.  j a  v a  2 s  .  c o  m*/

    return String.valueOf(result);
}

From source file:org.spf4j.zel.operators.LongOperators.java

private static Number powLongInt(final Long a, final Number b) {
    long result;/*  ww w  .  jav a  2 s .  c o  m*/
    try {
        result = LongMath.checkedPow(a, b.intValue());
    } catch (ArithmeticException e) {
        return BigInteger.valueOf(a).pow(b.intValue());
    }
    return result;
}