diff options
author | Daniel Friesel <daniel.friesel@uos.de> | 2019-09-17 07:57:14 +0200 |
---|---|---|
committer | Daniel Friesel <daniel.friesel@uos.de> | 2019-09-17 07:57:14 +0200 |
commit | b41df1d896fdcb191959fc3f18105f52571a688c (patch) | |
tree | b847c072d567ab2b6e04cbc80511f6467dc7b0bc | |
parent | 2fcf0bb98675e1b0a2efa9b9f04de1393005b289 (diff) |
Mod: Allow initialization from another Mod object
-rw-r--r-- | lib/modular_arithmetic.py | 2 |
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: |