Search:

Type: Posts; User: grumpy

Search: Search took 0.06 seconds.

  1. Replies
    7
    Views
    1,241

    When doing any logical test, a zero value is...

    When doing any logical test, a zero value is false, and a non-zero value is true.

    So "if (i%2)" is shorthand for "if (i%2 != 0)". This is true in all conditionals (loop conditions, ternary ?:,...
  2. Replies
    7
    Views
    1,241

    i%2 is the remainder on dividing the integer i by...

    i%2 is the remainder on dividing the integer i by 2. If i is a multiple of 2, i%2 is zero. Otherwise it is 1.

    Depending on age of your compiler, there are some caveats if i is negative (since...
Results 1 to 2 of 2