Fix overflow/underflow detection.