Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>if (0)</code> evaluates the predicate <code>0</code> as a binary value. Binary values in C use integers, where zero means false and non-zero means true. Therefore, 0 will always evaluate to false.</p> <p>For binary operators, being right- or left-associative determines the order that otherwise equally important operators will be processed. Consider the subtraction operator:</p> <pre><code>37 - 10 - 4 </code></pre> <p>Both <code>-</code> are equal precedence so which should we evaluate first? Well, <code>-</code> is left-associative so we do:</p> <pre><code>(37 - 10) - 4 ==&gt; (27) - 4 ==&gt; 23 </code></pre> <p>If the <code>-</code> operator were right-associative, we would do:</p> <pre><code>37 - (10 - 4) ==&gt; 37 - 6 ==&gt; 31 </code></pre> <p>Equality (<code>=</code>) is right-associative because we might chain equalities together. So, if we see</p> <pre><code>// a and b are initialized to 0 a = b = 45 </code></pre> <p>Both <code>=</code> are equal precedence so we evaluate right to left and do:</p> <pre><code>a = (b = 45) // b receives 45 a = 45 // a receives 45 </code></pre> <p>If we were to go left-right, we'd get an unexpected result:</p> <pre><code>(a = b) = 45 // a receives 0 b = 45 // b receives 45 </code></pre> <p>For unary operators, however, ordering can only matter when multiple unary operators affect the same value. For example, let's do:</p> <pre><code>char x = 0xFF bool y = !~x </code></pre> <p>These unary operators are right-associative, so we do:</p> <pre><code>!(~0xFF) ==&gt; !(0x0) ==&gt; true </code></pre> <p>In the example you showed, the negation operators affecting <code>A</code> and <code>E</code> didn't have "equal precedence" because they didn't have the same operand. So, associativity doesn't apply.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload