home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!ames!data.nas.nasa.gov!taligent!apple!cambridge.apple.com!cartier@math.uqam.ca
- From: cartier@math.uqam.ca (Guillaume Cartier)
- Newsgroups: comp.lang.lisp.mcl
- Subject: Re: Binary manipulation
- Message-ID: <9211232141.AA21358@mipsmath.math.uqam.ca>
- Date: 23 Nov 92 21:41:10 GMT
- Sender: info-mcl-request@cambridge.apple.com
- Lines: 39
- Approved: comp.lang.lisp.mcl@Cambridge.Apple.C0M
-
- <---
- | What is the best way to do binary manipulation of data within MCL?
- | I need to do the equivalent of shifts, ands, nors, ors, etc., but the problem
- | I'm having is doing these with integers and fixnums How would you convert the following
- | to mcl:
- |
- | {
- | short var1 47;
- | unsigned long var2 0x322459;
- |
- | *((var1 & 0x7 << 3) + var2)
- | }
- |
- | going back and forth between MCL fixnum and bit-arrays (without losing data)?
- |
- | Jeffrey
- --->
-
- If I understand your problem correctly you don't need bit-arrays
- and can use the whole bunch of CLtL2's boolean functions that will
- manipulate integers. See sections 12.7 and 12.8 of CLtL2.
-
- Examples:
-
- ? (logior 3 4 5)
- 7
- ? (lognot 45)
- -46
- ? (logand 23 1 456)
- 0
-
- Guillaume.
-
- *********************************************************************
- * Guillaume Cartier (514) 844-5294 (maison) *
- * L.A.C.I.M. (514) 987-4290 (bureau) *
- * Universite du Quebec a Montreal (514) 987-8477 (telecopieur) *
- * Montreal, Quebec, Canada cartier@math.uqam.ca (internet) *
- *********************************************************************
-