// JAVA public static String getNetFileSizeDescription(long bytes) { if (bytes == 0) return "0B"; final String[] units = new String[]{"B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"}; int digitGroups = (int) (Math.log10(bytes) / Math.log10(1024)); return new DecimalFormat("#,##0.##").format(bytes / Math.pow(1024, digitGroups)) + "" + units[digitGroups]; } // JS 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(3) + ' ' + sizes[i]; }
正文
字节转换
此篇文章发布距今已超过284天,您需要注意文章的内容或图片是否可用!
转载请注明出处
-- 展开阅读全文 --
还没有评论,来说两句吧...