From b0d8a2f5f5718ba3fea628cad7bcbbc76c6a140c Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Sat, 21 Dec 2024 16:19:39 +0100 Subject: Fix possible overflow with assignment operations --- zmodn.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'zmodn.h') diff --git a/zmodn.h b/zmodn.h index 562aa22..f161ad1 100644 --- a/zmodn.h +++ b/zmodn.h @@ -17,9 +17,9 @@ public: Zmod operator+(const Zmod& z) const { return int64 + z.int64; } Zmod operator-(const Zmod& z) const { return int64 - z.int64; } Zmod operator*(const Zmod& z) const { return int64 * z.int64; } - Zmod operator+=(const Zmod& z) { return int64 += z.int64; } - Zmod operator-=(const Zmod& z) { return int64 -= z.int64; } - Zmod operator*=(const Zmod& z) { return int64 *= z.int64; } + Zmod operator+=(const Zmod& z) { return (*this) = int64 + z.int64; } + Zmod operator-=(const Zmod& z) { return (*this) = int64 - z.int64; } + Zmod operator*=(const Zmod& z) { return (*this) = int64 * z.int64; } bool operator==(const Zmod& z) const { return int64 == z.int64; } bool operator!=(const Zmod& z) const { return int64 != z.int64; } -- cgit v1.3