` 0 is equal to 1 ?
then why -1 is being printed
` 0 is equal to 1?
Only sentences (things with truth-values) can be negated, and 0 is not a sentence, it’s a numeral.
So ~0 != 1.
means ~0 is -1 ?
but ~1 =0 ,so ~0 must be also equal to 0.
You don’t get it. You can’t negate numerals. You can only negate sentences with truth-values. And integers are not sentences.
then ~0 = ?
and how is -1 equal 1111… ?
There isn’t any valid value for ~0 as it is a numeral and any other number as they are not a sentence with truth value.
but i checked it ~0 , -1 is being printed .
1 Like
It must be because the way C++ compiler are designed but I don’t know for sure. What I know is mathematically you can’t negate 0.