From: Miss Coffee Bean
Subject: binary to decimal type stuff in LISP - help?
Date: 
Message-ID: <e80eb560.0105192033.6bd5aacb@posting.google.com>
I'm interested in writing some LISP code to work with lists of binary
digits so that you can convert them to decimal and vice versa
Also some things like two's compliment or sign magnitude mathematical
operations and normalizing the result before outputing and other stuff
like that...

Does anyone know of a good place to look at some example source code
or to read up on how to do this?
I'm a little confused on the technicalities of the operations!

Thanks, guys  :-)

From: Kent M Pitman
Subject: Re: binary to decimal type stuff in LISP - help?
Date: 
Message-ID: <sfwvgmwilyt.fsf@world.std.com>
········@aol.com (Miss Coffee Bean) writes:

> 
> I'm interested in writing some LISP code to work with lists of binary
> digits so that you can convert them to decimal and vice versa
> Also some things like two's compliment or sign magnitude mathematical
> operations and normalizing the result before outputing and other stuff
> like that...
> 
> Does anyone know of a good place to look at some example source code
> or to read up on how to do this?
> I'm a little confused on the technicalities of the operations!
> 
> Thanks, guys  :-)

Look in the Common Lisp HyperSpec (make sure you have Release 5 or above,
with the white page backgrounds, it comes with the LispWorks Personal 
release that is downloadable free from Xanalys, but oddly is not the one
that is on their web site).  Older versions of CLHS, like the one sported
at the Xanalys web site, have a less-good index that doesn't index the #
reader macros nor the ~ format ops.

Look up the #* syntax in the Master index (under non-alphabetic).
 #*1010101010100000111
is a syntax for a bit-vector.  That is, Lisp already has a primitive syntax
for reading and writing vectors of element-type BIT, called BIT-VECTORS.

You can also look up bit-vector and see that there are a number of operations
on them.  Look in the symbol index under BIT-xxx for various operations.

You should also look at integers, which in Lisp are arbitrary
precision, so can masquerade as bit vectors also.  For these, numerous
operations are available. Look in the symbol index under LOGxxx for the
operations in question.

You can get binary/octal/hex information out of an integer using LDB and DPB
(which are load-byte and deposit-byte, respectively).  Also, the Lisp reader
will already print a number in an arbitrary radix by setting *PRINT-BASE*
to an appropriate value or by using WRITE with an appropriate :BASE argument.

You should make sure you understand what CL already provides before you start
off trying to extend it.
From: Miss Coffee Bean
Subject: Re: binary to decimal type stuff in LISP - help?
Date: 
Message-ID: <e80eb560.0105201039.207083e6@posting.google.com>
Thank you Kent!
Its actually just an intro to LISP type program so we are supposed to keep it really simple... 

I'll try to figure something out  :-)



Kent M Pitman <······@world.std.com> wrote in message news:<···············@world.std.com>...
> ········@aol.com (Miss Coffee Bean) writes:
> 
> > 
> > I'm interested in writing some LISP code to work with lists of binary
> > digits so that you can convert them to decimal and vice versa
> > Also some things like two's compliment or sign magnitude mathematical
> > operations and normalizing the result before outputing and other stuff
> > like that...
> > 
> > Does anyone know of a good place to look at some example source code
> > or to read up on how to do this?
> > I'm a little confused on the technicalities of the operations!
> > 
> > Thanks, guys  :-)
> 
> Look in the Common Lisp HyperSpec (make sure you have Release 5 or above,
> with the white page backgrounds, it comes with the LispWorks Personal 
> release that is downloadable free from Xanalys, but oddly is not the one
> that is on their web site).  Older versions of CLHS, like the one sported
> at the Xanalys web site, have a less-good index that doesn't index the #
> reader macros nor the ~ format ops.
> 
> Look up the #* syntax in the Master index (under non-alphabetic).
>  #*1010101010100000111
> is a syntax for a bit-vector.  That is, Lisp already has a primitive syntax
> for reading and writing vectors of element-type BIT, called BIT-VECTORS.
> 
> You can also look up bit-vector and see that there are a number of operations
> on them.  Look in the symbol index under BIT-xxx for various operations.
> 
> You should also look at integers, which in Lisp are arbitrary
> precision, so can masquerade as bit vectors also.  For these, numerous
> operations are available. Look in the symbol index under LOGxxx for the
> operations in question.
> 
> You can get binary/octal/hex information out of an integer using LDB and DPB
> (which are load-byte and deposit-byte, respectively).  Also, the Lisp reader
> will already print a number in an arbitrary radix by setting *PRINT-BASE*
> to an appropriate value or by using WRITE with an appropriate :BASE argument.
> 
> You should make sure you understand what CL already provides before you start
> off trying to extend it.
From: Kent M Pitman
Subject: Re: binary to decimal type stuff in LISP - help?
Date: 
Message-ID: <sfw3d9zlsxa.fsf@world.std.com>
········@aol.com (Miss Coffee Bean) writes:

> Thank you Kent!

> Its actually just an intro to LISP type program so we are supposed
> to keep it really simple...

Sigh.  I think a good intro to Lisp would teach you what Lisp has, or at
least acknowledge that they're asking you to write what is already there 
as an exercise... Having you write stuff as if Lisp had no support for 
this kind of thing is a little sad...

Btw, when asking questions relating to homework, always say that you are
doing homework.  People don't like accidentally doing others' homework.
They'll still help you, but their mode of interaction is different in that
case.
From: Miss Coffee Bean
Subject: Re: binary to decimal type stuff in LISP - help?
Date: 
Message-ID: <e80eb560.0105201921.21ae0050@posting.google.com>
Yeah I tried to figure some things out and I ended up posting a
simpler question in hopes to get at least a start on it..

Thank you :)


Kent M Pitman <······@world.std.com> wrote in message news:<···············@world.std.com>...
> ········@aol.com (Miss Coffee Bean) writes:
> 
> > Thank you Kent!
>  
> > Its actually just an intro to LISP type program so we are supposed
> > to keep it really simple...
> 
> Sigh.  I think a good intro to Lisp would teach you what Lisp has, or at
> least acknowledge that they're asking you to write what is already there 
> as an exercise... Having you write stuff as if Lisp had no support for 
> this kind of thing is a little sad...
> 
> Btw, when asking questions relating to homework, always say that you are
> doing homework.  People don't like accidentally doing others' homework.
> They'll still help you, but their mode of interaction is different in that
> case.
From: john Latala
Subject: Re: binary to decimal type stuff in LISP - help?
Date: 
Message-ID: <Pine.BSI.4.05L.10105201752000.17984-100000@shell.golden.net>
On 19 May 2001, Miss Coffee Bean wrote:

> Does anyone know of a good place to look at some example source code
> or to read up on how to do this?

"The Art of Computer Programming" by Donald E. Knuth is a three volume
set. One of the volumes, can't remember which one right at this moment,
goes into great detail on the implemenation and theory behind writing your
own arithmentic operations.

-- 
john R. Latala
········@golden.net
From: Reini Urban
Subject: Re: binary to decimal type stuff in LISP - help?
Date: 
Message-ID: <9fbpf9$qm7$1@fstgss02.tu-graz.ac.at>
john Latala <········@golden.net> wrote:
: On 19 May 2001, Miss Coffee Bean wrote:

> Does anyone know of a good place to look at some example source code
:> or to read up on how to do this?

: "The Art of Computer Programming" by Donald E. Knuth is a three volume
: set. One of the volumes, can't remember which one right at this moment,
: goes into great detail on the implemenation and theory behind writing your
: own arithmentic operations.

Volume 2 (3rd ed), page 319-329: Radix Conversion
-- 
Reini Urban
http://xarch.tu-graz.ac.at/acadwiki/AutoLispFaq