# Need help understanding !NOT

• 06-14-2004
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?

• 06-14-2004
Zach L.
Umm... Will this do it for you?
Code:

```int convert(bool in) {   return ((in) ? 1 : 0); }```
• 06-14-2004
Salem
!0 is 1
! of anything which isn't zero is 0

Imagine !x as if ( x == 0 )
• 06-14-2004
master5001
Quote:

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.