leohxj
4/4/2014 - 2:57 AM

round number with JS

round number with JS

function roundedNum(somenum) {
    return (0.5 + somenum) | 0;
}

function roundedNum(somenum) {
    return ~~(0.5 + somenum);
}

function roundedNum(somenum) {
    return (0.5 + somenum) << 0;
}