Function: math-integer-log
math-integer-log is a byte-compiled function defined in
calc-math.el.gz.
Signature
(math-integer-log X B)
Source Code
;; Defined in /usr/src/emacs/lisp/calc/calc-math.el.gz
(defun math-integer-log (x b)
(let ((pows (list b))
(pow (math-sqr b))
next
sum n)
(while (not (Math-lessp x pow))
(setq pows (cons pow pows)
pow (math-sqr pow)))
(setq n (ash 1 (1- (length pows)))
sum n
pow (car pows))
(while (and (setq pows (cdr pows))
(Math-lessp pow x))
(setq n (/ n 2)
next (math-mul pow (car pows)))
(or (Math-lessp x next)
(setq pow next
sum (+ sum n))))
(cons (equal pow x) sum)))