二进制转十进制
http://bbs.xdcad.net/
(defun sr (str)
(mapcar '(lambda (x) (- x 48)) (vl-string->list str))
)
(defun fbin->ten (lst)
(setq tenlst nil)
(setq flst (mapcar '(lambda (x) 0) lst))
(mapcar '(lambda (y)
(setq flag y)
(setq flst (mapcar '(lambda (x)
(setq z (rem (+ (* 2 x) flag) 10))
(setq flag (/ (+ (* 2 x) flag) 10))
z
)
flst
)
)
)
lst
)
(vl-string-left-trim "0" (apply 'strcat (mapcar '(lambda (x) (itoa x)) (reverse flst))))
)
(fbin->ten (sr (getstring "请输入二进制数n=")))
进'制专家。还有八进呢。谢谢分享!
434939575 发表于 2014-12-14 18:22 static/image/common/back.gif
进'制专家。还有八进呢。谢谢分享!
不是“进制专家”,只是对“大数”运算感兴趣
页:
[1]