home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / MAGAZINE / MISC / PCTV1N5.ZIP / BITSTUFF.C < prev    next >
Encoding:
Text File  |  1990-09-14  |  410 b   |  21 lines

  1. /* In the functions below, the bits are numbered from right */
  2. /* to left. That is, the least significant bit is bit 0.    */
  3.  
  4. void setbit(unsigned *word, int n)
  5. /* Sets bit in word */
  6. {
  7.   *word |= (1 << n);
  8. }
  9.  
  10. void resetbit(unsigned *word, int n)
  11. /* Clears bit in word */
  12. {
  13.   *word &= ~(1 << n);
  14. }
  15.  
  16. void togglebit(unsigned *word, int n)
  17. /* Toggles bit in word */
  18. {
  19.   *word ^= (1 << n);
  20. }
  21.