Non-decimal radices/Convert: Difference between revisions

Line 842:
(defun base-n-to-decimal (number &key (base 16))
(read-from-string (format nil "#~dr~d" base number)))</lang>
 
Yet another approach uses FORMAT's ~R in conjunction with ~V for passing arguments to directives (this assumes input as string)
<lang lisp>(defun change-base (number input-base output-base)
(format nil "~vr" output-base (parse-integer number :radix input-base)))</lang>
 
=={{header|D}}==
Anonymous user