home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sys / amiga / programm / 11623 < prev    next >
Encoding:
Text File  |  1992-07-25  |  1.9 KB  |  45 lines

  1. Newsgroups: comp.sys.amiga.programmer
  2. Path: sparky!uunet!gatech!concert!samba!usenet
  3. From: Scott.Maxwell@bbs.oit.unc.edu (Scott Maxwell)
  4. Subject: Re: Programming-BOOLEAN-compression
  5. Message-ID: <1992Jul25.052153.15878@samba.oit.unc.edu>
  6. Sender: usenet@samba.oit.unc.edu
  7. Nntp-Posting-Host: lambada.oit.unc.edu
  8. Organization: Extended Bulletin Board Service
  9. References: <Quentin_Snow.08d3@fcircus.sat.tx.us>
  10. Date: Sat, 25 Jul 1992 05:21:53 GMT
  11. Lines: 32
  12.  
  13. In article <Quentin_Snow.08d3@fcircus.sat.tx.us> Quentin_Snow@fcircus.sat.tx.us (Quentin Snow) writes:
  14.  
  15. >I am writing a program of which I will be able to enter about 10 - 12     
  16. >YES/NO (boolean) type answers to various questions I write.  This
  17. >information will then be stored into a user structure.  
  18.  
  19. [ ... ]
  20.  
  21. >There has to be a way for me to store the answers in one "numeric"
  22. >variable (compressed) form, them extract them.  This way I can store the
  23. >answers in one variable, then read them back when necessary.
  24.  
  25. [ ... ]
  26.  
  27.     You didn't specify a language. If you're using C, you want to use
  28. a bit field. If Pascal, use a PACKED ARRAY [whatever..whatever] OF BOOLEAN
  29. -- though be forewarned that many/most Pascals will store each element as
  30. a byte, not a single bit. Modula-2 may have something similar; I dunno.
  31.  
  32.     In the unlikely event that you're using a C compiler that doesn't
  33. support bit fields, get a better compiler. Or, failing that, use shifts
  34. and masks to store and extract the data in a short int (you said you only
  35. needed 10-12 bits; a short consists of 16 bits, so there's some waste
  36. there but not much).
  37.  
  38. --
  39. Scott Maxwell (CSMAXWEL@ECUVM1.BITNET or Scott.Maxwell@bbs.oit.unc.edu)
  40. --
  41.    The opinions expressed are not necessarily those of the University of
  42.      North Carolina at Chapel Hill, the Campus Office for Information
  43.         Technology, or the Experimental Bulletin Board Service.
  44.            internet:  bbs.oit.unc.edu or 152.2.22.80
  45.