4 ms·
> For example, the way signed and unsigned numbers are defined in the C standard What do you mean?
by slver 5y ago
> For example, the way signed and unsigned numbers are defined in the C standard
What do you mean?
- MauranKilom 5y agoPresumably something like the representation of signed numbers being implementation defined (instead of two's complement as is virtually always the case nowadays).
- akkartik 5y agoYeah. The standard avoids obvious guarantees because of some computer you never heard of. And then compiler writers use the standard as license to mess with the guarantee on _your_ computer.
- MaxBarraclough 5y agoI know this doesn't address the point about the C standard itself, but: • GCC and Clang both accept the -fwrapv argument, causing the compiler to guarantee that signed overflow will wrap, like in Java • The latest C++ standard mandates that signed integer types use two's complement representation (signed overflow remains undefined behaviour)
- akkartik 5y agoRandom example from searching right now: https://www.learncpp.com/cpp-tutorial/unsigned-integers-and-why-to-avoid-them https://www.learncpp.com/cpp-tutorial/unsigned-integers-and-...