In C language, the ! operator represents the logical NOT operation, which converts the operand to a Boolean value and returns its opposite: 0 (false) if the operand is non-zero. If the operand has a zero value, returns 1 (true).
!a is equal to what in C language
In C language,!
operator represents the logical NOT operation, which converts the operand to a Boolean value and returns its opposite value.
The calculation rules for logical NOT operations are:
So, for variable a
:
a
is not If !a
is zero (not equal to 0), then
If a
is zero (equal to 0), then Example:
Assume the value of
is 5, then: <div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false"><code>!a = !(5) // 5 不等于 0
!a = 0 // 返回 0(假)</code></pre><div class="contentsignin">Copy after login</div></div>
On the contrary, if
<code>!a = !(0) // 0 等于 0 !a = 1 // 返回 1(真)</code>
The above is the detailed content of !What is equal to a in C language?. For more information, please follow other related articles on the PHP Chinese website!