News for hackers. Stuff that matters.
Re:Counting up vs. counting down by Lagged2Death on Thursday November 19, 2015 @09:41AM (#10594989)
But if it's unsigned this will never be true either...

Conceptually, it works through promotion. -1 is cast to unsigned/size_t before the test, which then succeeds. At the assembly level, a 32-bit -1 is 0xFFFFFFFF, which is also the result of the underflow of i, so it works at that level, too.

At any rate, it worked in the compiler I tried it with.

Re:Counting up vs. counting down by Retric on Thursday November 19, 2015 @10:42AM (#10595326)
Technically no language was specified, so depending on specific casting rules is risky. This could easily just throw a compilation error.
Re:Counting up vs. counting down by cperciva on Thursday November 19, 2015 @11:16AM (#10595564)
When you're reading tedu's blog, it's safe to assume that anything which looks like C is C.