3 ms·
It's funny I think the opposite: I kind of like the idea of an iNaN, but I've never been bothered by the asymmetry of INT_MIN and INT_MAX. I also don't think ov
by __david__ 15y ago
It's funny I think the opposite: I kind of like the idea of an iNaN, but I've never been bothered by the asymmetry of INT_MIN and INT_MAX. I also don't think overflow should necessarily cause an iNaN right away. "INT_MAX + 10 - 20" is legit, even though it overflows twice.
> In any case, processor vendors aren't about to change the way they do integer math so this discussion, while quite interesting, is completely academic.
I thought so too initially, but really every processor already has a status register that shows you when overflow happened (otherwise big integer algorithms would be hard) which is all you really need for this proposal. But it does require a bunch of tests around and integer arithmetic which makes it unlikely to be a good candidate for a C language addition (a language whose main impetus is speed).
- modeless 15y agoHe addresses delaying iNaN generation in Premise 3. Adding explicit overflow tests after every integer operation is clearly a non-starter for a systems programing language.
- jerf 15y ago'"INT_MAX + 10 - 20" is legit, even though it overflows twice.' In general, maybe so. But in systems programming? What could that possibly mean that is not a bug? There are answers to that, but since the answers are going to be <1% corner cases it doesn't justify defaulting to the dangerous case while requiring one to jump through hoops to get the safe case. If you desperately need "INT_MAX + 10 - 20", ask for it.