Draw cut involving &

Version: 4.02
Hardware: ATHLON MP
OS: linux Fedora 3
Severity: normal
Reproducable: always

The following commands differ in brackets around logical AND.
They produce different histograms

h4 is a root tree with CWN ntuple in it.
I am plotting adc1 for those events when det equals 9 and bits 1 and 17 of
fera_reg are 1.

Obviously logic is screwed up if I do not put brackets around logical AND.

h4->Draw(“adc1”,"det == 9 && ((fera_reg & 1) == 1) && (fera_reg & pow(2.0,17) == pow(2.0,17)) ")

h4->Draw(“adc1”,"det == 9 && ((fera_reg & 1) == 1) && ( (fera_reg & pow(2.0,17)) == pow(2.0,17)) ")

By the way , how can I check bits in a word without calculating 2 to 17 order ?

Hi,

The behavior is actually correct. The operator “bitwise and” has a lower precedence than operator ==. Hence

a & b == c is strictly equivalent to a & (b==c)Refer to your favorite C or C++ reference guide for more detail on precedence.
As far as pow(2.0,17) you can simply replace it with:

Cheers,
Philippe.