Hacker News new | ask | show | jobs
by briantakita 1930 days ago
> why does the bitwise AND have higher precedence than logical AND?

Why is this precedence weird? Bitwise AND tends to be used to transform data while a logical AND tends to be used for control flow.

2 comments

I meant equals having a higher precedence than bitwise AND.

As in:

    if (x & 2 == 2)
...is actually parsed as:

    if (x & (2 == 2))
...which isn’t intuitive.
See the above example from dmr himself