A ring is a standard mathematical structure describing objects which can be added and multiplied. Do C# and Java signed long
s obey all the properties of a ring? For example, is multiplication by Long.MIN_VALUE always associative and distributive? Assume we are in an unchecked context.
(definition copied from Wikipedia)
A ring is a set R equipped with binary operations + and · satisfying the following three sets of axioms, called the ring axioms.
- R is an abelian group under addition, meaning that
- (a + b) + c = a + (b + c) for all a, b, c in R (+ is associative).
- a + b = b + a for all a, b in R (+ is commutative).
- There is an element 0 in R such that a + 0 = a for all a in R (0 is the additive identity).
- For each a in R there exists −a in R such that a + (−a) = 0 (−a is the additive inverse of a).
- R is a monoid under multiplication, meaning that:
- (a ⋅ b) ⋅ c = a ⋅ (b ⋅ c) for all a, b, c in R (⋅ is associative).
- There is an element 1 in R such that a ⋅ 1 = a and 1 ⋅ a = a for all a in R (1 is the multiplicative identity).
- Multiplication is distributive with respect to addition:
- a ⋅ (b + c) = (a ⋅ b) + (a ⋅ c) for all a, b, c in R (left distributivity).
- (b + c) ⋅ a = (b ⋅ a) + (c ⋅ a) for all a, b, c in R (right distributivity).
A commutative ring is one where multiplication is commutative (meaning a ⋅ b = b ⋅ a).