-1

i++;
++i;
It's the same shit

Comments
  • 4
    In a for loop it is. But look at the following example:
    int a=0; int b=++a; //a=1, b=1
    int a=0; int b=a++; //a=1, b=0
  • 4
    you know some spaceship crash because a dude thought int and float are the same shit
  • 1
    @simus Ariane5 July 1996:

    The on-board computer crashed 36.7 sec. after the start when he tried to convert the horizontal speed value of 64 bit floating point representation to 16 bit signed integer: -+ b1 b1 b2... b15.
    The corresponding number was greater than 2^{15}=32768 and created an overflow.

    The steering system collapsed and gave up control to a second, identical unit. Self-destruct was triggered because the engines threatened to break off.
  • 0
    @tracktraps
    i didn't know about the self destructive part,
    jeez, it's a little bit extrem.
  • 1
    @simus btw:

    ariane5: loss approx. $500 million for rockets and satellites. Development costs approx. 7 billion dollars.

    There are dozens of examples:
    Pentium processor division error 1994
    Patriot missile error 1991
    Loss of the Mars Climate Orbiter 1998
    The Denver Case Debacle
    Venus Mariner 1 is lost on the way in 1962
    US Federal Reserve System
    Bank of America

    Worth a look: https://translate.google.de/transla...
  • 0
    @tracktraps thanks! look fun! and full of mistake to avoid! let's get paranoid
  • 2
    C operator precedence and evaluation order fun:

    i=0, i+++i = 1
    i=0, i+ ++i = 2
    i=0, i++ +i = 1
    i=0, i++ + ++i = 2
    i=0, i+++ ++i = 2
    i=0, ++i+ ++i = 4
    i=0, ++i+ i++ = 3
    i=0, ++i+i++ = 3

    And it can be continued forever:
    i=0, ++i+i+++i+++i+++i+++i+++i+++i+++i+++i+++i+++i+++i+++i+++i+++i+++i+++i+++i+++i++ = 192
Add Comment