Hacker News new | past | comments | ask | show | jobs | submit login

> the ++ operator only acts on integer types

no, I believe it works on pointer types and enums as well




It is also defined for floats.

Using it seems like a bad move though -- for large values it can round back to the input value.

Indeed, the following stupid test program works, although it may heat up your laptop slightly.

    #include <stdio.h>

    void main()
    {
      float C   = 1.0f;
      float Cin = 0.0f;
      int i=0;

      while (Cin != C)
      {
        i++;
        Cin = C;
        C++;
      }
      printf("%i %e\n", i, C/C++);
    }
And, it finally lets us confirm what the mathematicians never could. When does the limit happen? 16777216. No further questions.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: