Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

My bigger problem in the past has been loops of the type:

    for(int i = 0; i < a-b; ++i) f(a[i]);
If a < b, then this works cleanly, with no loops occuring. However:

    for(unsigned i = 0; i < a-b; ++i) f(a[i]);
Instead casts a-b to a large unsigned integer, and horrible things happen. Of course, I could add a pre-check to my loop, but I don't really want to (and of course, I have to remember to do that).


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

Search: