News for hackers. Stuff that matters.
Re:Solutions to Integer Overflow by catnaroek on Saturday September 03, 2016 @11:11AM (#12419470)
Wrapping arithmetic makes perfect sense in many ways:

(0) It is still a commutative ring, so it has the most important nice algebraic properties of number arithmetic: addition and multiplication are associative and commutative, multiplication distributes over addition, etc.

(1) It is the ideal building block for implementing the very big integers that high-level languages need.

Trapping on overflow is a relatively minor concession in elegance: You are admitting that you want all integers, but, for efficiency reasons, constrain yourself to those that fit into some fixed amount of space. The worst that can happen is that you can't compute the result you want. You never compute a nonsensical result.

Saturating arithmetic is an abomination and simply shouldn't exist.

Re:Solutions to Integer Overflow by grandinj on Saturday September 03, 2016 @12:36PM (#12419823)
Saturating math is mainly a DSP thing, where it can be very useful in mimicking the behavior of some analog circuits. And it makes some algorithms have much nicer boundary behavior.
Re:Solutions to Integer Overflow by catnaroek on Saturday September 03, 2016 @02:24PM (#12420373)
I confess my ignorance. Maybe in a DSP context saturating arithmetic makes sense.