private static int modf(LuaCallFrame callFrame, int nArguments) {
        BaseLib.luaAssert(nArguments >= 1, "Not enough arguments");
        double x = getDoubleArg(callFrame,1,names[MODF]);

        boolean negate = false;
        if (MathLib.isNegative(x)) {
            negate = true;
            x = -x;
        }
        double intPart = Math.floor(x);
        double fracPart;
        if (Double.isInfinite(intPart)) {
            fracPart = 0;
        } else {
            fracPart = x - intPart;
        }
        if (negate) {
            intPart = -intPart;
            fracPart = -fracPart;
        }
        callFrame.push(LuaState.toDouble(intPart), LuaState.toDouble(fracPart));
        return 2;
    }
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