CCoding Style - Be Clear
Revision as of 09:30, 23 June 2015 by Jshankar (1 revision imported: EdWiki -- Emsys pages from Shukra)
- 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;