3 ms·
Yes. In many ways: 1) it’s pretty important to have easy syntax for math with overflow checks. Otherwise there will be bugs. Bad bugs. We have those and it suc
by pizlonator 6y ago
Yes. In many ways:
1) it’s pretty important to have easy syntax for math with overflow checks. Otherwise there will be bugs. Bad bugs. We have those and it sucks.
2) it’s pretty important that if the overflow wraps in ISA then it wraps in language semantics but C just says “meh whatever” for signed overflow. That leads to even more bugs.
- GeorgeTirebiter 6y agoThe HP3000 had "SPL" - Systems Programming Language -- as its way of doing what C does. It had a specific syntax for checking the error codes: if <> then <whatever> so whatever previous arithmetic did, you could check the machine's flags directly. Can't do that in C. https://en.wikipedia.org/wiki/Systems_Programming_Language https://en.wikipedia.org/wiki/Systems_Programming_Language
- the5avage 6y agoAt the time C was designed not all machines did represent signed integers in 2 complement. Therefore it was not possible to define behavior for signed overflow. They probably should change that 2020^^ GCC has intrinsics for integer math with overflow checks
- ncmncm 6y agoC++ formalized two's complement already. Formalizing power-of-two word size and 8-bit bytes might come.