timeit.js
// return the value rounded to 3 digits of precision
return the value rounded to 3 digits of precision
return the value rounded to 3 digits of precision
function number_precision3( value ) {
    var pad = 0;
    while (value >= 1000) {
        value /= 10;
        pad += 1;
    }
    if (value >= 100) return ('' + (value + .5)).slice(0, 4) + str_repeat('0', pad);   
    if (value >= 10) return ('' + (value + .05)).slice(0, 4);   
    if (value >= 1) return ('' + (value + .005)).slice(0, 4);   
    return ('' + value + .0005).slice(1, 5);                    
}
function number_precision3 ( value ) { var pad = 0 ; while ( value >= 1000 ) { value /= 10 ; pad += 1 ; } if ( value >= 100 ) return ( '' + ( value + .5 ) ) . slice ( 0 , 4 ) + str_repeat ( '0' , pad ) ; if ( value >= 10 ) return ( '' + ( value + .05 ) ) . slice ( 0 , 4 ) ; if ( value >= 1 ) return ( '' + ( value + .005 ) ) . slice ( 0 , 4 ) ; return ( '' + value + .0005 ) . slice ( 1 , 5 ) ; }
return the value rounded to 3 digits of precision
return the value rounded to 3 digits of precision
// 123.4 => '123' // 12.34 => '12.3' // 1.234 => '1.23' // .1234 => '.123'