Hi,
Terry,
Your code works fine until 702 which returns "ZZ", but 703 returns "[A" instead of "AAA".
Patrick,
Your code works fine until 51 which returns "AY", but 52 returns "B@" instead of "AZ".
Here's another way, using a recursive form (assuming num is a strictely positive integer) :
(defun num2alpha (num / r)
(if (< num 27)
(chr (+ 64 num))
(if (= 0 (setq r (rem num 26)))
(strcat (num2alpha (1- (/ num 26))) "Z")
(strcat (num2alpha (/ num 26)) (chr (+ 64 r)))
)
)
)
(num2alpha 702) -> "ZZ"
(num2alpha 703) -> "AAA"
(num2alpha (* 26 703)) -> "ZZZ"
(num2alpha (1+ (* 26 703))) -> "AAAA"