code: public static long pow(long l, int exp) {
          BigInteger bi = BigInteger.valueOf(l).pow(exp);
          if(bi.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) > 0 || bi.compareTo(BigInteger.valueOf(Long.MIN_VALUE)) < 0) {
              throw new IllegalArgumentException("pow(" + l + "," + exp + ") exceeds Long.MAX_VALUE");
          }
          return bi.longValue();
      }
docs: Java.lang.pow only works on doubles; this fixes that.
  Safe version of pow that relies on BigInteger that can raise a long to an int exponential. Uses BigInteger
  internally to ensure this is done
  correctly and does a check on the value to ensure it can safely be converted into a long
  
  @param l
  a long
  @param exp
  exponent
  @return l to the power of exp
  @throws IllegalArgumentException
  if the resulting value exceeds Long.MAX_VALUE