home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / lisp / mcl / 1685 < prev    next >
Encoding:
Internet Message Format  |  1992-11-23  |  1.6 KB

  1. 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
  2. From: cartier@math.uqam.ca (Guillaume Cartier)
  3. Newsgroups: comp.lang.lisp.mcl
  4. Subject: Re: Binary manipulation
  5. Message-ID: <9211232141.AA21358@mipsmath.math.uqam.ca>
  6. Date: 23 Nov 92 21:41:10 GMT
  7. Sender: info-mcl-request@cambridge.apple.com
  8. Lines: 39
  9. Approved: comp.lang.lisp.mcl@Cambridge.Apple.C0M
  10.  
  11. <---
  12. | What is the best way to do binary manipulation of data within MCL?
  13. | I need to do the equivalent of shifts, ands, nors, ors, etc., but the problem
  14. | I'm having is doing these with integers and fixnums  How would you convert the following
  15. | to mcl:
  16. | {
  17. |         short var1 47;
  18. |         unsigned long var2 0x322459;
  19. |         *((var1 & 0x7 << 3) + var2)
  20. | }
  21. | going back and forth between MCL fixnum and bit-arrays (without losing data)?
  22. |         Jeffrey
  23. --->
  24.  
  25. If I understand your problem correctly you don't need bit-arrays
  26. and can use the whole bunch of CLtL2's boolean functions that will
  27. manipulate integers. See sections 12.7 and 12.8 of CLtL2.
  28.  
  29. Examples:
  30.  
  31. ? (logior 3 4 5)
  32. 7
  33. ? (lognot 45)
  34. -46
  35. ? (logand 23 1 456)
  36. 0
  37.  
  38. Guillaume.
  39.  
  40. *********************************************************************
  41. * Guillaume Cartier                 (514) 844-5294 (maison)         *
  42. * L.A.C.I.M.                        (514) 987-4290 (bureau)         *
  43. * Universite du Quebec a Montreal   (514) 987-8477 (telecopieur)    *
  44. * Montreal, Quebec, Canada          cartier@math.uqam.ca (internet) *
  45. *********************************************************************
  46.