
21 Jan
2013
21 Jan
'13
11:36 p.m.
Scott Wood scottwood@freescale.com writes:
On 01/19/2013 03:30:30 AM, Albert ARIBAUD wrote:
/* what I favor */ clk_is_enabled = ((reg_val >> 9) & 1) ? true: false; ip_is_enabled = clk_is_enabled && pwd_is_enabled; if (clk_is_enabled) { ...
rather than assigning them 'zero/nonzero', or using bitwise ops on booleans, or testing against boolean constants (although I concede that the first line below wins over its counterpart above as far as concision is concerned).
Conciseness can be improved with "!!((reg_val >> 9) & 1)".
x & 1 is already either zero or one. Any further operations are nothing but obfuscation.
--
Måns Rullgård
mans@mansr.com