home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lclint.zip / lclint-2_3h-os2-bin.zip / test / tests2.2a / bitops.c < prev    next >
Text File  |  1997-09-03  |  478b  |  31 lines

  1. int f (int i1, int i2, unsigned u1, unsigned u2)
  2. {
  3.   int x = i1 & i2; /* not unsigned */
  4.   unsigned u = u1 & i2;
  5.   short s = i1 & i2;  /* not unsigned */
  6.   short s2 = i1 + i2;
  7.  
  8.   u = u1 | u2;
  9.   u = i1 << 3; /* left operand not unsigned */
  10.   u = u1 >> 4; /* okay */
  11.   u = u1 >> i1;
  12.  
  13.   u >>= 3;
  14.   u = i1 ^ u1; /* ! not unsigned */
  15.   u = u1 ^ i1; /* ! not unsigned */
  16.  
  17.   return x;
  18. }
  19.  
  20. /*
  21.  
  22. >>, >>=
  23. <<, <<=
  24.     warn if not unsigned
  25.  
  26. &, &=
  27. |, |=
  28. ^ (XOR), ^=
  29.    warn if not unsigned
  30. */
  31.