summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2019-09-17 07:57:14 +0200
committerDaniel Friesel <daniel.friesel@uos.de>2019-09-17 07:57:14 +0200
commitb41df1d896fdcb191959fc3f18105f52571a688c (patch)
treeb847c072d567ab2b6e04cbc80511f6467dc7b0bc /lib
parent2fcf0bb98675e1b0a2efa9b9f04de1393005b289 (diff)
Mod: Allow initialization from another Mod object
Diffstat (limited to 'lib')
-rw-r--r--lib/modular_arithmetic.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/modular_arithmetic.py b/lib/modular_arithmetic.py
index 03cb7f8..baf979a 100644
--- a/lib/modular_arithmetic.py
+++ b/lib/modular_arithmetic.py
@@ -8,6 +8,8 @@ class Mod:
__slots__ = ['val','mod']
def __init__(self, val, mod):
+ if isinstance(val, Mod):
+ val = val.val
if not isinstance(val, int):
raise ValueError('Value must be integer')
if not isinstance(mod, int) or mod<=0: