Re: Bits from a stream
- From: Peter Seibel <peter@xxxxxxxxxxxxxxx>
- Date: Mon, 20 Mar 2006 13:44:32 GMT
Zach Beane <xach@xxxxxxxx> writes:
"Alan Manuel K. Gloria" <almkglor@xxxxxxxxx> writes:
I'm currently trying to figure out how bits work in CL.
You can access the bits of an integer with functions like LDB and
LOGAND. You can produce integers with modified bits with functions
like DPB and LOGIOR. You can perform bitwise shifts with ASH. You can
test individual bits with LOGBITP or groups of bits with LOGTEST.
There are many more functions for accessing and operating on the bits
of an integer. See the numbers dictionary for a list:
http://www.lispworks.com/documentation/HyperSpec/Body/c_number.htm
Basically I need to do some compression on some data I'm storing - the
way I keep my data is rather amenable to compression, but compressing
it requires access to individual bits. I would like to store and
retrieve data from a file, so I will need access to bits in a stream.
I have written a few bitstream functions for a Flash file
reader/writer. They are available here:
http://www.xach.com/lisp/cl-flash/bitio.lisp
It will allow you to both read and write variable-length contiguous
bits across octet boundaries in an (UNSIGNED-BYTE 8) stream. There
isn't much to it.
You might also want to check out Chapter 24, "Parsing Binary Files" of
my book wherein I discuss how to build a library for parsing various
kinds of binary files.
<http://www.gigamonkeys.com/book/practical-parsing-binary-files.html>
-Peter
--
Peter Seibel * peter@xxxxxxxxxxxxxxx
Gigamonkeys Consulting * http://www.gigamonkeys.com/
Practical Common Lisp * http://www.gigamonkeys.com/book/
.
- Follow-Ups:
- Re: Bits from a stream
- From: Alan Manuel K. Gloria
- Re: Bits from a stream
- References:
- Bits from a stream
- From: Alan Manuel K. Gloria
- Re: Bits from a stream
- From: Zach Beane
- Bits from a stream
- Prev by Date: Re: Bits from a stream
- Next by Date: Re: UI and CLISP
- Previous by thread: Re: Bits from a stream
- Next by thread: Re: Bits from a stream
- Index(es):
Relevant Pages
|