Created
October 6, 2014 05:16
-
-
Save mooz/a5015f8a4570bfc30e71 to your computer and use it in GitHub Desktop.
Display `size-byte' in various units
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
(defun my:byte-to-various-units (size-byte) | |
"Display `size-byte' in various units." | |
(interactive "nBytes: ") | |
(let ((size size-byte) | |
(size-kib size-byte)) | |
(with-output-to-temp-buffer "*unit*" | |
(princ (format "%d B\n-----------\n" size-byte)) | |
(dolist (unit '("K" "M" "G" "T" "P")) | |
(setq size (/ size 1000.0)) | |
(setq size-kib (/ size-kib 1024.0)) | |
(princ (format (concat "%g %siB" | |
"\t\t" | |
"%g %sB" | |
"\n") | |
size-kib unit | |
size unit)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment