1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Math.floor = function(n) { return ~~n; }; Math.frac = function(n){ return n - Math.floor(n); }; Math.round = function(n) { return Math.floor(n) + (Math.frac(n) >= 0.5) }; Math.ceil = function(n) { return Math.floor(n) + !!(Math.frac(n)) };