home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!europa.asd.contel.com!howland.reston.ans.net!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!agate!ames!saimiri.primate.wisc.edu!sal.wisc.edu!alan
- From: alan@sal.wisc.edu (Alan Watson)
- Subject: Re: Question to test general C knowledge
- Message-ID: <1992Dec21.001419.20865@sal.wisc.edu>
- Organization: Space Astronomy Lab, Madison WI
- References: <1992Dec14.164400.59891@ns1.cc.lehigh.edu> <1992Dec17.190025.11325@athena.mit.edu> <1992Dec20.234400.11271@thunder.mcrcim.mcgill.edu>
- Date: Mon, 21 Dec 1992 00:14:19 GMT
- Lines: 16
-
- In article <1992Dec20.234400.11271@thunder.mcrcim.mcgill.edu> mouse@thunder.mcrcim.mcgill.edu (der Mouse) writes:
-
- [ On whether to replace i % 4 with i & 3 and i / 2 with i >> 1: ]
-
- >The compiler often cannot tell whether it is correct to do so. If the
- >variable is declared signed (probably implicitly), but cannot in fact
- >be negative at that point
-
- In this case I would usually write one of:
-
- (unsigned) i % 4
- (unsigned) i / 2
-
- which give the compiler all the information it needs. This technique
- is one of the few ways in C that one can pass optimization hints to the
- compiler.
-