Created
July 29, 2016 22:58
-
-
Save GitHub30/0014ad130e85ead17f2455c4a8430eee to your computer and use it in GitHub Desktop.
readable_size.js
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 readable_size(size){ | |
var units = ['B', 'KB', 'MB', 'GB', 'TB']; | |
var i = Math.floor(Math.log(size)/Math.log(1024)); | |
return Math.floor(size/Math.pow(1024, i)) + units[i]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment