home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!europa.asd.contel.com!darwin.sura.net!spool.mu.edu!olivea!charnel!sifon!thunder.mcrcim.mcgill.edu!mouse
- From: mouse@thunder.mcrcim.mcgill.edu (der Mouse)
- Newsgroups: comp.lang.c
- Subject: Re: Question to test general C knowledge
- Message-ID: <1992Dec20.230703.10039@thunder.mcrcim.mcgill.edu>
- Date: 20 Dec 92 23:07:03 GMT
- References: <1992Dec16.192652.65097@ns1.cc.lehigh.edu>
- Organization: McGill Research Centre for Intelligent Machines
- Lines: 24
-
- In article <1992Dec16.192652.65097@ns1.cc.lehigh.edu>, dsbb@ns1.cc.lehigh.edu (D. SPENCER BEECHER) writes:
- > D. SPENCER BEECHER) writes:
- >>> varname%3
- >>> varname&0x02
- >> Well, [...]
-
- > 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.
-
- It also doesn't work. For example, if x holds 7, x&2 is 2 whereas your
- expression produces 3. (And, as you note, changes x.)
-
- I'm also not sure whether , or ?: has higher precedence. For that to
- work correctly, it has to be interpreted as (x%=4),((x>1)?x:0), but I'm
- not sure it wouldn't be (((x%=4),x)>1)?x:0 instead, which I *think*
- produces undefined behavior.
-
- der Mouse
-
- mouse@larry.mcrcim.mcgill.edu
-