4 ms·
You can't take advantage of two's complement arithmetic if you want portable C, though.
by torrent-of-ions 12y ago
You can't take advantage of two's complement arithmetic if you want portable C, though.
- userbinator 12y agoAre there any machines in widespread use today that don't use two's complement? I guess if there were, we'd hear a lot more about this issue... I know that some mainframes are an example, but they're somewhat of a niche.
- nitrogen 12y agoSigned integer overflow is undefined in C, so optimizers can do really weird things to code that has overflows.
- anaphor 12y agoYes, see: http://people.csail.mit.edu/nickolai/papers/wang-undef.pdf http://people.csail.mit.edu/nickolai/papers/wang-undef.pdf
- kps 12y agoAnd see John Regehr's ( http://blog.regehr.org/ http://blog.regehr.org/, of the headline article) other posts. He's written a great deal about undefined behaviour in C/C++ and how modern compilers handle it. Check the ‘Compilers’ and ‘Software Correctness’ categories.