Hello People,
I cannot understand how this expression gets evaluated ..

1+~0

From what I know ~ has higher priority . So the expression becomes
1+(~0)= 2

But the answer that I got was 0. I know it is some thing to do with the fact that ~ is right associative but I cannot put my finger on it

Recommended Answers

All 2 Replies

~0 is "all bits set", not 1. !0 is 1.

Damm.... I feel like such an ass .....:@

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.