Human-friendly summary of some number of bytes.
Function:
(defun vl-nice-bytes (bytes) (declare (xargs :guard (natp bytes))) (let ((__function__ 'vl-nice-bytes)) (declare (ignorable __function__)) (b* (((when (< bytes 1000)) (cat (natstr bytes) "B")) (kbytes (truncate bytes 1000)) ((when (< kbytes 1000)) (cat (natstr kbytes) "." (natstr (truncate (rem bytes 1000) 100)) "K")) (mbytes (truncate kbytes 1000)) ((when (< mbytes 1000)) (cat (natstr mbytes) "." (natstr (truncate (rem kbytes 1000) 100)) "M")) (gbytes (truncate mbytes 1000))) (cat (natstr gbytes) "." (natstr (truncate (rem mbytes 1000) 100)) "G"))))
Theorem:
(defthm stringp-of-vl-nice-bytes (b* ((str (vl-nice-bytes bytes))) (stringp str)) :rule-classes :type-prescription)