public static double ipow(double base, int exponent) {
        boolean inverse = false;
        if (MathLib.isNegative(exponent)) {
            exponent = -exponent;
            inverse = true;
        }
        double b = 1;
        for (b = (exponent & 1) != 0 ? base : 1, exponent >>= 1; exponent != 0; exponent >>= 1) {
            base *= base;
            if ((exponent & 1) != 0) {
                b *= base;
            }
        }
        if (inverse) {
            return 1 / b;
        }
        return b;
    }
Rounds to keep <em>precision</em> decimals. Rounds towards even numbers.
@param x the number to round
@param precision the precision to round to. A precision of 3 will for instance round 1.65432 to 1.654
@return the rounded number
main/src/main/java/cgeo/geocaching/wherigo/kahlua/stdlib/MathLib.java