From ... From: Erik Naggum Subject: Re: How do I convert from binary string to integer? Date: 1997/05/06 Message-ID: <3071931359799285@naggum.no>#1/1 X-Deja-AN: 239785956 References: <336E9423.54E6@ix.netcom.com> mail-copies-to: never Organization: Naggum Software; +47 2295 0313; http://www.naggum.no Newsgroups: comp.lang.lisp * Carolyn Goodman Plampin | Given an arbitrary number of binary characters in a string, say "10000" | or "10010001" as examples, how do I convert this into an integer? just like you would turn any string of digits in any base to an integer. | Going from integer to string is easy via format ~b but going in the other | direction is not so obvious to me. (write ) will output the integer as a string of digits in the base according to the value of the special varibale *print-base*. the corresponding special variable when reading is *read-base*. (let ((*print-base* 2)) (write 4711)) -> 1001001100111 => 4711 (setq *print-base* 2) => 10 4711 => 1001001100111 (setq *print-base* 10 *read-base* 2) => 2 1001001100111 => 4711 relevant functions are `read-from-string' and `parse-integer'. note that `write' and `parse-integer' take keyword arguments that obviate the need to bind the special variables yourself. #\Erik -- if we work harder, will obsolescence be farther ahead or closer?