News for hackers. Stuff that matters.
Re:Signed Integers Are Two’s Complement by markrages on Thursday May 31, 2018 @10:13AM (#17196426)
Yes, it is annoying to rrad comments that assume overflow is always a programming error.

You can store the angle as a union of signed and unsigned type. Do arithmetic on the unsigned member, where overflow is defined. (Both members are equivalent angles)

Re:Signed Integers Are Two’s Complement by kazinator on Thursday May 31, 2018 @11:37AM (#17197110)
Or you could just convert from the unsigned to the signed type, rather than dragging unions into it.

This conversion doesn't have undefined behavior; it produces an implementation defined result.

C programs can simulate two's complement math using unsigned types, avoiding UB. Then rely on IB to convert between signed and unsigned.

Re:Signed Integers Are Two’s Complement by sanxiyn on Thursday May 31, 2018 @10:17AM (#17196457)
Not always, but overflows are usually bugs. This is replicated finding of dynamic overflow checking tools, over and over.
Re:Signed Integers Are Two’s Complement by kazinator on Thursday May 31, 2018 @11:39AM (#17197119)
And if overflow is well-defined, then those tools must switch your C dialect to a non-ISO-C conforming one in order to do their job.