private static int fmod(LuaCallFrame callFrame, int nArguments) {
        BaseLib.luaAssert(nArguments >= 2, "Not enough arguments");
        double v1 = getDoubleArg(callFrame,1,names[FMOD]);
        double v2 = getDoubleArg(callFrame,2,names[FMOD]);

        double res;
        if (Double.isInfinite(v1) || Double.isNaN(v1)) {
            res = Double.NaN;
        } else if (Double.isInfinite(v2)) {
            res = v1;
        } else {
            v2 = Math.abs(v2);
            boolean negate = false;
            if (MathLib.isNegative(v1)) {
                negate = true;
                v1 = -v1;
            }
            res = v1 - Math.floor(v1/v2) * v2;
            if (negate) {
                res = -res;
            }
        }
        callFrame.push(LuaState.toDouble(res));
        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