home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / c / 18719 < prev    next >
Encoding:
Internet Message Format  |  1992-12-21  |  1.2 KB

  1. Path: sparky!uunet!europa.asd.contel.com!darwin.sura.net!spool.mu.edu!olivea!charnel!sifon!thunder.mcrcim.mcgill.edu!mouse
  2. From: mouse@thunder.mcrcim.mcgill.edu (der Mouse)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Question to test general C knowledge
  5. Message-ID: <1992Dec20.230703.10039@thunder.mcrcim.mcgill.edu>
  6. Date: 20 Dec 92 23:07:03 GMT
  7. References: <1992Dec16.192652.65097@ns1.cc.lehigh.edu>
  8. Organization: McGill Research Centre for Intelligent Machines
  9. Lines: 24
  10.  
  11. In article <1992Dec16.192652.65097@ns1.cc.lehigh.edu>, dsbb@ns1.cc.lehigh.edu (D. SPENCER BEECHER) writes:
  12. > D. SPENCER BEECHER) writes:
  13. >>> varname%3
  14. >>> varname&0x02
  15. >> Well, [...]
  16.  
  17. > x&0x02 may be represented with modulo as:
  18.  
  19. >   x%=4,x>1?x:0;
  20.  
  21. > though this changes the value of x, where x&0x02 makes no assignment.
  22.  
  23. It also doesn't work.  For example, if x holds 7, x&2 is 2 whereas your
  24. expression produces 3.  (And, as you note, changes x.)
  25.  
  26. I'm also not sure whether , or ?: has higher precedence.  For that to
  27. work correctly, it has to be interpreted as (x%=4),((x>1)?x:0), but I'm
  28. not sure it wouldn't be (((x%=4),x)>1)?x:0 instead, which I *think*
  29. produces undefined behavior.
  30.  
  31.                     der Mouse
  32.  
  33.                 mouse@larry.mcrcim.mcgill.edu
  34.