Do C# and Java longs form a commutative ring? -
a ring standard mathematical structure describing objects can added , multiplied. c# , java signed long
s obey properties of ring? example, multiplication long.min_value associative , distributive? assume in unchecked context.
(definition copied wikipedia)
a ring set r equipped binary operations + , · satisfying following 3 sets of axioms, called ring axioms.
- r abelian group under addition, meaning
- (a + b) + c = + (b + c) a, b, c in r (+ associative).
- a + b = b + a, b in r (+ commutative).
- there element 0 in r such + 0 = in r (0 additive identity).
- for each in r there exists −a in r such + (−a) = 0 (−a additive inverse of a).
- r monoid under multiplication, meaning that:
- (a ⋅ b) ⋅ c = ⋅ (b ⋅ c) a, b, c in r (⋅ associative).
- there element 1 in r such ⋅ 1 = , 1 ⋅ = in r (1 multiplicative identity).
- multiplication distributive respect addition:
- a ⋅ (b + c) = (a ⋅ b) + (a ⋅ c) a, b, c in r (left distributivity).
- (b + c) ⋅ = (b ⋅ a) + (c ⋅ a) a, b, c in r (right distributivity).
a commutative ring 1 multiplication commutative (meaning ⋅ b = b ⋅ a).
on platforms signed values overflow defined wrapping, signed , unsigned values behave in isomorphic fashion when fed +
, -
, *
, &
, ^
, |
, <<
, , ~
operators, or when performing unchecked cast smaller type. behave differently when used relational operators, >>
, %
, , /
operators, when casting or promoting larger types.
because unsigned values of given size behave ring, signed values well. note because of implicit promotion int
, smaller types may not behave arithmetic rings because applying +
, *
values of such type may yield not value of type.
Comments
Post a Comment