;;;截录:自明经信道
;;;十进制转换为其它进制
;;;-------------------------------------------------------------------
(defun DECIMALTOBASE (BASE VAL / RESULT TMP)
(setq RESULT "")
(while (> VAL 0)
(setq RESULT (strcat (if (> (setq TMP (rem VAL BASE)) 9)
(chr (+ TMP 55))
(itoa TMP)
)
RESULT
)
VAL (fix (/ VAL BASE))
)
)
RESULT
)
;;;截录:明经信道
;;;其它进制转换为十进制
;;;-------------------------------------------------------------------
(defun BASETODECIMAL (BASE VAL / POS POWER RESULT TMP)
(setq POS (1+ (strlen VAL))
POWER -1
RESULT 0
VAL (strcase VAL)
)
(while (> (setq POS (1- POS)) 0)
(setq
RESULT (+ RESULT
(* (if (> (setq TMP (ascii (substr VAL POS 1))) 64)
(- TMP 55)
(- TMP 48)
)
(expt BASE (setq POWER (1+ POWER)))
)
)
)
)
RESULT
)
;;;-------------------------------------------------------------------