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