From: ·····@
Subject: How to change number in binary radix into char?
Date: 
Message-ID: <b6psm7$39d$1@galaxy.uci.agh.edu.pl>
Hello
       In fact, the problem I can't figure out with is a little bit
       different. I've got a string consisting of 0 and 1. Every 8 decimals
I'd
       like to change into char (that's cos i have to write it into a
       file without wasting space). Actually the exact questions i'd
       like to ask are following:
       - how to change char into binary digit and vice versa
       - how to cut out a substring. eg. from "000111" i'd like to
       receive only "000"
       - is threre a simple possibility to change a binary number into 256
       radix number, cos that'd be the most comfortable for me
       - is there a function allowing to check, if one string is the
       initial part of the second one

       txh for help

·····@

From: Henrik Motakef
Subject: Re: How to change number in binary radix into char?
Date: 
Message-ID: <873ckv30oa.fsf@interim.henrik-motakef.de>
······@" <·····@op.pl> writes:

> - how to change char into binary digit and vice versa

You can convert between characters and numbers with char-int and
int-char. 

> - how to cut out a substring. eg. from "000111" i'd like to
>   receive only "000"

* (subseq "000111" 0 3)
=> "000"

> - is threre a simple possibility to change a binary number into 256
> radix number, cos that'd be the most comfortable for me

You are actually dealing with strings, not numbers, right? Then you
can probably play with *read-base* and *print-base*.

> - is there a function allowing to check, if one string is the
> initial part of the second one

* (string= "000" "000111" :end2 3)
T

hth
Henrik
From: Barry Margolin
Subject: Re: How to change number in binary radix into char?
Date: 
Message-ID: <UXgka.10$1E5.444@paloalto-snr1.gtei.net>
In article <··············@interim.henrik-motakef.de>,
Henrik Motakef  <··············@web.de> wrote:
>······@" <·····@op.pl> writes:
>> - is threre a simple possibility to change a binary number into 256
>> radix number, cos that'd be the most comfortable for me
>
>You are actually dealing with strings, not numbers, right? Then you
>can probably play with *read-base* and *print-base*.

Also, PARSE-INTEGER takes the radix as a parameter.  And you can use
~<radix>R in FORMAT to convert to digits in a particular radix.

-- 
Barry Margolin, ··············@level3.com
Genuity Managed Services, a Level(3) Company, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
From: Joerg Hoehle
Subject: Re: How to change number in binary radix into char?
Date: 
Message-ID: <uhe97sr5n.fsf@dont.t-systems.UCE.spam.no.com>
Henrik Motakef <··············@web.de> writes:

> You can convert between characters and numbers with char-int and
> int-char. 
I thought that was old Common Lisp the Languague first edition
(aka. CLtL1), from 1984, and it had once been deprecated. But
it's in ANSI-Common Lisp. Yet I use code-char and char-code these days.

> > - is there a function allowing to check, if one string is the
> > initial part of the second one
> 
> * (string= "000" "000111" :end2 3)
> T
You may need
(string/= "000" "000111")
3
depending on your situation.

You may also wish to lookup the function MISMATCH

And (write 8 :base 2) for output.

Regards,
	Jorg Hohle
Telekom/T-Systems Technology Center