;;; bnum.el ;;; ;;; Copyright (C) 1997, 1998, 2004, 2007, 2008 Thien-Thi Nguyen ;;; ;;; This file is part of ttn's personal elisp library, released under ;;; the terms of the GNU General Public License as published by the ;;; Free Software Foundation; either version 3, or (at your option) any ;;; later version. There is NO WARRANTY. See file COPYING for details. ;;; Description: Convert a number to a binary string. Also a list variant. ;;;###autoload (defun bnum (n) "Returns positive number N represented in boolean, as a string." (if (= 0 n) "0" (let ((s "")) (while (/= 0 n) (setq s (concat (if (= 0 (% n 2)) "0" "1") s)) (setq n (/ n 2))) s))) ;;;###autoload (defun blist (&rest nums) "Returns list of positive NUMS represented in boolean, as a string." (mapcar 'bnum nums)) (provide 'bnum) ;;; bnum.el ends here