标签:color top code java floor blog osi return rip
//文件大小转换 function bytesToSize(bytes) { if (bytes === 0) return ‘0 B‘; var k = 1024; sizes = [‘B‘, ‘KB‘, ‘MB‘, ‘GB‘, ‘TB‘, ‘PB‘, ‘EB‘, ‘ZB‘, ‘YB‘]; i = Math.floor(Math.log(bytes) / Math.log(k)); return (bytes / Math.pow(k, i)).toPrecision(4) + ‘ ‘ + sizes[i]; //toPrecision(3) 后面保留一位小数,如1.0GB
//return (bytes / Math.pow(k, i)).toPrecision(3) + ‘ ‘ + sizes[i]; }
标签:color top code java floor blog osi return rip
原文地址:http://www.cnblogs.com/EasonJim/p/6257074.html