private int random(LuaCallFrame callFrame, int nArguments) {
        Random random = callFrame.thread.state.random;
        if (nArguments == 0) {
            callFrame.push(LuaState.toDouble(random.nextDouble()));
            return 1;
        }

        double tmp = getDoubleArg(callFrame,1,names[RANDOM]);
        int m = (int) tmp;
        int n;
        if (nArguments == 1) {
            n = m;
            m = 1;
        } else {
            tmp = getDoubleArg(callFrame,2,names[RANDOM]);
            n = (int) tmp;
        }
        callFrame.push(LuaState.toDouble(m + random.nextInt(n - m + 1)));

        return 1;
    }
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