将字节转化成其他单位

来源:互联网 发布:合同软件 编辑:程序博客网 时间:2024/05/10 05:51
    'readablizeBytes': function (bytes) {        var s = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB'];        var e = Math.floor(Math.log(bytes) / Math.log(1024));        return (bytes / Math.pow(1024, Math.floor(e))).toFixed(2) + " " + s[e];    }
原创粉丝点击