js,javascript四舍五入round

function round(arg) {
    var temp = arg < 0 ? -arg : arg,
        round_x = (10 * temp) % 10,
        round_D = arg % 1;
    if (round_x < 5) {
        return arg - round_D;
    } else {
        return arg - round_D + (arg > 0 ? 1 : -1);
    }
}