! Int

I was reading the arduino sample. Unrebounce. There is a statement.

int i = LOW
     I = ! i

What does it do?

What does it do?

Generate a compiler error.

You code fragment has numerous problems:

int i = LOW               // No semicolon at the end of the statement line
     I = ! i              // Variable I not defined, missing semicolon at end of statement line

If you fix the errors and add a few Serial.print() statements, you should be able to figure out what the expression does.

Nevertheless,

In C (and C++), the conversion from integer to boolean is that integer 0 is boolean false, anything else is boolean true. The conversion from boolean back to integer is that false becomes 0, true becomes 1. So !x, where x is an integer, turns zero into 1, and any nonzero value into 0.