It really depends. If you're using a language that supports booleans, you should use the boolean, not an integer, ie:
if (value == false)
or
if (value == true)
That being said, with real boolean types, it's perfectly valid (and typically nicer) to just write:
if (!value)
or
if (value)
There is really very little reason in most modern languages to ever use an integer for a boolean operation.
That being said, if you're using a language which does not support booleans directly, the best option here really depends on how you're defining true and false. Often, false
is 0, and true
is anything other than 0. In that situation, using if (i == 0)
(for false check) and if (i != 0)
for true checking.
If you're guaranteed that 0 and 1 are the only two values, I'd probably use if (i == 1)
since a negation is more complex, and more likely to lead to maintenance bugs.