News for hackers. Stuff that matters.
Re:Catching Integer Overflows in C by jerf on Tuesday August 02, 2011 @10:34AM (#2837244)
How is an abs function that can return a negative value not a flat-out bug‽ Seriously? It may still not be cool to end up with true_abs(MIN_INT) - 1 rather than the "real" value, but at least it won't be negative. That's really bad.
Re:Catching Integer Overflows in C by rcfox on Tuesday August 02, 2011 @10:45AM (#2837289)
Either way, you're going to have the incorrect number. When debugging, I'd rather have something that is very incorrect rather than having a mysterious off-by-one error.

Edit: The C99 standard acknowledges that abs(INT_MIN) isn't representable, so using abs(INT_MIN) is undefined.