From af80174a081bb60dc93e8070bc9915eb6fb5b2ae Mon Sep 17 00:00:00 2001 From: Kenneth Seet Date: Wed, 29 Jan 2025 00:35:37 +0800 Subject: [PATCH 1/2] Optimise relational operators --- include/operators/relational.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/operators/relational.hpp b/include/operators/relational.hpp index 460f915..9013565 100644 --- a/include/operators/relational.hpp +++ b/include/operators/relational.hpp @@ -59,7 +59,7 @@ bool BigInt::operator<(const BigInt& num) const { */ bool BigInt::operator>(const BigInt& num) const { - return !((*this < num) or (*this == num)); + return num < *this; } @@ -69,7 +69,7 @@ bool BigInt::operator>(const BigInt& num) const { */ bool BigInt::operator<=(const BigInt& num) const { - return (*this < num) or (*this == num); + return !(*this > num); } From a4e2b842e63d460a859b724947ee83846ff56016 Mon Sep 17 00:00:00 2001 From: Kenneth Seet Date: Wed, 29 Jan 2025 00:37:42 +0800 Subject: [PATCH 2/2] Optimise relational operators --- include/operators/relational.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/operators/relational.hpp b/include/operators/relational.hpp index 9013565..8322d07 100644 --- a/include/operators/relational.hpp +++ b/include/operators/relational.hpp @@ -69,7 +69,7 @@ bool BigInt::operator>(const BigInt& num) const { */ bool BigInt::operator<=(const BigInt& num) const { - return !(*this > num); + return !(num < *this); }