# Thread: Need help understanding !NOT

1. ## Need help understanding !NOT

Good afternoon everyone.

I have a simple assignment statement:

var=((5*67)+!50)

My problem is understanding the ! (NOT). If something is not 50, it is false, which returns a value of 0. I would calculate var=335. Is this correct? I know the !50 is a logical operation, which I read as returning TRUE or False. My difficulty is converting that T/F return value (0 or 1) and using it as part of an arithmetic calculation. Is there some place I can read up on this to help grasp the concept?

2. Umm... Will this do it for you?
Code:
int convert(bool in) {
return ((in) ? 1 : 0);
}

3. !0 is 1
! of anything which isn't zero is 0

Imagine !x as if ( x == 0 )

Good afternoon everyone.
var=((5*67)+!50)
Code:
var = ((5*67)+!50);
var = ((5*67)+0);
Are the same. Indeed your example is just a waste of code since you would normally just do

Code:
var = 335; // as you had previously mentioned
You should use the ! operator with variables, not constants.

Code:
var = !x; // acceptable code
var = !0; // code that only will generate confusion later.
There is nothing wrong with using ! with constants except for the fact that it obfuscates your code.