• 10_0
    link
    fedilink
    33 years ago

    can someone explain the joke please?

    • Adda
      link
      fedilink
      7
      edit-2
      3 years ago

      i++ is a simple statement increasing the value of i by one. The statement from the picture does the same thing, the code is just really obfuscated. The boolean value false is usually represented as zero, true as one. Therefore, we have false, negation operator ! makes it true. When we apply the minus operator, the programming language implicitly converts true to 1. Adding minus, we get -1. Operator -= takes the value from the left operand and subtracts from it the value of the right operand. The result is stored to the left operand. Therefore, we have a value in i, let’s say 5, we take the value and subtract -1, making it 5-(-1), get 6 and return the result to i. Here you have your increment of i, i++.

        • Adda
          link
          fedilink
          13 years ago

          Where exactly? Do you mean i = i + 1;? Yes, that would be the same statement – producing the same result. You could also use i += 1; so you spare one character you don’t have to type (i) – this is used in Python for example, because Python doesn’t use ++ operator for increment, it doesn’t know ++ operator in fact. But it turns out programmers are lazy and increment by one is so often used that some programming languages (such as C or C++) defines ++ operator as even a quicker way to increment by one.