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

  1. Path: sparky!uunet!spool.mu.edu!yale.edu!jvnc.net!netnews.upenn.edu!netnews.cc.lehigh.edu!ns1.cc.lehigh.edu!dsbb
  2. From: dsbb@ns1.cc.lehigh.edu (D. SPENCER BEECHER)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Question to test general C knowledge
  5. Message-ID: <1992Dec16.192652.65097@ns1.cc.lehigh.edu>
  6. Date: 16 Dec 92 19:26:52 GMT
  7. Organization: Lehigh University
  8. Lines: 29
  9.  
  10. D. SPENCER BEECHER) writes:
  11. >|> How about:
  12. >|> What is the difference between:
  13. >|> varname%3
  14. >|> and
  15. >|> varname&0x02
  16. >|>
  17. >|> and why might one be more advantageous to use?
  18. >
  19. >Well, one of them extracts the remainder after division of `varname'
  20. >by three and the other extracts the second from the bottom bit (which
  21. >is considerably different from remainder modulo three).
  22. ...etc
  23. >J. Giles
  24.  
  25. and I thought my question was harder than all that.  I only
  26. got one respondant indicating they are equivalent.
  27.  
  28. the %3 (I believe) does not have a bit-manipulated closed form
  29.  
  30. x&0x02 may be represented with modulo as:
  31.  
  32.   x%=4,x>1?x:0;
  33.  
  34. though this changes the value of x, where x&0x02 makes no assignment.
  35. -- 
  36.                    _ _     _ _     _ _
  37.   -Spence         [O.O]   )x.x(   )O.O(
  38.                     O       O      -*-
  39.