Created
March 4, 2014 09:02
-
-
Save gucheen/9342778 to your computer and use it in GitHub Desktop.
文件大小单位转换
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function readablizeBytes(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]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment