1 line
313 B
JavaScript
1 line
313 B
JavaScript
function round(a,e,r){var _,c,s,t;if(e|=0,_=Math.pow(10,e),a*=_,t=a>0|-(a<0),s=a%1==.5*t,c=Math.floor(a),s)switch(r){case"2":case"PHP_ROUND_HALF_DOWN":a=c+(t<0);break;case"3":case"PHP_ROUND_HALF_EVEN":a=c+c%2*t;break;case"4":case"PHP_ROUND_HALF_ODD":a=c+!(c%2);break;default:a=c+(t>0)}return(s?a:Math.round(a))/_} |