4 ms·
Those are all integers. https://en.wikipedia.org/wiki/Modular_arithmetic https://en.wikipedia.org/wiki/Modular_arithmetic - "The modern approach to modular arit
by Asooka 2y ago
Those are all integers. https://en.wikipedia.org/wiki/Modular_arithmetic https://en.wikipedia.org/wiki/Modular_arithmetic - "The modern approach to modular arithmetic was developed by Carl Friedrich Gauss in his book Disquisitiones Arithmeticae, published in 1801." They have been integers for over 200 years now.
- thaumasiotes 2y agoWrapping around is correct integer behavior; clamping ("5 + 1 = 5") isn't. Clamping implies immediately that all positive numbers are equal to zero.
- TapamN 2y agoTrue correct behavior would have that if a > b, then a + c > b + c also holds true for all integers, but that isn't guaranteed for wrapping (or clamping.) (e.g. if 250 > 1, then 250 + 10 > 1 + 10 should be true, but with 8-bit wrapping you would get 4 > 11, which is false.)
- d_tr 2y agoBut if you write a + b and the result is wrapped around or saturated, it's not integer addition. It's something else and should be written in another way in code and have a different name. I am aware of modular arithmetic. If you have a type named "int" with an operation called "addition", and that operation is not actually integer addition... it's wrong.