3 ms·
> We trap on division because it is objectively a programmer error that has no obvious right answer. Defining (2^31 - 1) + 1 = -2^31 is no more of an "obvious
by marshray 13y ago
> We trap on division because it is objectively a programmer error that has no obvious right answer.
Defining (2^31 - 1) + 1 = -2^31 is no more of an "obvious right answer" than defining N/0 = 42 for all N. It's just one that we computer engineers have been trained to accept because it is occasionally useful.
But it's still madness which discourages us from using tools that emit more correct code.
> A consistently not taken branch has very, very close to 0 overhead in a modern processor.
Except the half a dozen or so bytes it consumes in the cache.
Nevertheless, I concede that others have thought about this a lot more than I have and done so with hard data in front of them.