// 转换内存字节数
function formatMemorySize(byteCount) {
if (byteCount < 1024) {
return byteCount + ' B';
} else if (byteCount < 1024 * 1024) {
var kilobytes = byteCount / 1024;
return kilobytes.toFixed(2) + ' KB';
} else if (byteCount < 1024 * 1024 * 1024) {
var megabytes = byteCount / (1024 * 1024);
return megabytes.toFixed(2) + ' MB';
} else if (byteCount < 1024 * 1024 * 1024 * 1024) {
var gigabytes = byteCount / (1024 * 1024 * 1024);
return gigabytes.toFixed(2) + ' GB';
} else {
var terabytes = byteCount / (1024 * 1024 * 1024 * 1024);
return terabytes.toFixed(2) + ' TB';
}
}
手机内存字节数转换单位
最新推荐文章于 2024-06-20 15:06:48 发布