4 ms·
You can only observe whether the representation is 2s-complement or not if you can see what wrapping does.
by tomsmeding 5y ago
You can only observe whether the representation is 2s-complement or not if you can see what wrapping does.
- MaxBarraclough 5y agoThat doesn't sound right. You can use the union trick in C (but not C++, strictly speaking) to read the bit-pattern of a signed integer as an unsigned integer, for example. [0] Overflow of signed integer types remains undefined behaviour in both C and C++. A compiler is free to make a promise like signed integer overflow is always handled with wrapping or signed integer overflow is always handled with saturation. (GCC has a flag, -fwrapv, to enable guaranteed wrapping. [1]) [0] https://stackoverflow.com/a/25664954/ https://stackoverflow.com/a/25664954/ [1] https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html