From efc08126f7119569112b336f0cd73eefdf9737b5 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 18 Jan 2022 17:18:06 -0600 Subject: Um --- lisp/acdw.el | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'lisp/acdw.el') diff --git a/lisp/acdw.el b/lisp/acdw.el index 17741ab..a96e6a7 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el @@ -248,5 +248,29 @@ With optional ARG (\\[universal-argument]), just split." (interactive "P") (+split-window-then :below arg)) +(defun +bytes (number unit) + "Convert NUMBER UNITs to bytes. +UNIT can be one of :kb, :mb, :gb, :tb, :pb, :eb, :zb, :yb; :kib, :mib, :gib, +:tib, :pib, :eib, :zib, :yib." + (* number (pcase unit + ;; Base 10 units + (:kb 1000) + (:mb (* 1000 1000)) + (:gb (* 1000 1000 1000)) + (:tb (* 1000 1000 1000 1000)) + (:pb (* 1000 1000 1000 1000 1000)) + (:eb (* 1000 1000 1000 1000 1000 1000)) + (:zb (* 1000 1000 1000 1000 1000 1000 1000)) + (:yb (* 1000 1000 1000 1000 1000 1000 1000 1000)) + ;; Base 2 units + (:kib 1024) + (:mib (* 1024 1024)) + (:gib (* 1024 1024 1024)) + (:tib (* 1024 1024 1024 1024)) + (:pib (* 1024 1024 1024 1024 1024)) + (:eib (* 1024 1024 1024 1024 1024 1024)) + (:zib (* 1024 1024 1024 1024 1024 1024 1024)) + (:yib (* 1024 1024 1024 1024 1024 1024 1024 1024))))) + (provide 'acdw) ;;; acdw.el ends here -- cgit 1.4.1-21-gabe81