Function: kotl-label:int-to-alpha
kotl-label:int-to-alpha is a byte-compiled function defined in
klabel.el.
Signature
(kotl-label:int-to-alpha N)
Documentation
Return alphabetic representation of N as a string.
N may be an integer or a string containing an integer.
Source Code
;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/kotl/klabel.el
;; This handles partial alphabetic labels with a maximum single level
;; sequence of 17575 items, which = (1- (expt 26 3)), after which it gives
;; invalid results. This should be large enough for any practical cases.
(defun kotl-label:int-to-alpha (n)
"Return alphabetic representation of N as a string.
N may be an integer or a string containing an integer."
(if (stringp n) (setq n (string-to-number n)))
(let ((lbl "") pow26 exp26 quotient remainder)
(if (= n 0)
""
(setq pow26 (floor (log (if (= (mod (1- n) 26) 0) n (1- n))
26)))
(while (>= pow26 0)
(setq exp26 (expt 26 pow26)
quotient (floor (/ n exp26))
remainder (mod n exp26))
(if (= remainder 0)
(setq quotient (- quotient (1+ pow26))
n 26)
(setq n remainder
quotient (max 0 (1- quotient))))
(setq lbl (concat lbl (char-to-string (+ quotient ?a)))
pow26 (1- pow26)))
lbl)))