CCoding Style - Be Clear
Revision as of 06:51, 7 March 2012 by Jshankar (1 revision)
- Programmer’s endless creative energy is some times used to write the most concise possible code, or to find clever ways to achieve a result.
subkey = subkey >> ( bitoff – ( (bitoff >> 3) << 3 ) );
is equivalent to
subkey = subkey >> (bitoff & 0x7)
- It takes a while to puzzle out what the first version is doing; the second is shorter and clearer.
subkey >>= bitoff & 0x7;