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