From e236f1d2aee27a2d894fa4d35a363d0216d269d6 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Sun, 17 Nov 2024 13:27:52 -0500 Subject: [PATCH] LibCrypto: Define UnsignedBigInteger::operator<= We have all comparison operators except less-than-or-equal already. --- Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp | 5 +++++ Libraries/LibCrypto/BigInt/UnsignedBigInteger.h | 1 + 2 files changed, 6 insertions(+) diff --git a/Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp b/Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp index 1af99881465..4496a30c8d8 100644 --- a/Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp +++ b/Libraries/LibCrypto/BigInt/UnsignedBigInteger.cpp @@ -601,6 +601,11 @@ bool UnsignedBigInteger::operator<(UnsignedBigInteger const& other) const return false; } +bool UnsignedBigInteger::operator<=(UnsignedBigInteger const& other) const +{ + return *this < other || *this == other; +} + bool UnsignedBigInteger::operator>(UnsignedBigInteger const& other) const { return *this != other && !(*this < other); diff --git a/Libraries/LibCrypto/BigInt/UnsignedBigInteger.h b/Libraries/LibCrypto/BigInt/UnsignedBigInteger.h index 49839fc09e0..bf606d8fc95 100644 --- a/Libraries/LibCrypto/BigInt/UnsignedBigInteger.h +++ b/Libraries/LibCrypto/BigInt/UnsignedBigInteger.h @@ -128,6 +128,7 @@ public: [[nodiscard]] bool operator==(UnsignedBigInteger const& other) const; [[nodiscard]] bool operator!=(UnsignedBigInteger const& other) const; [[nodiscard]] bool operator<(UnsignedBigInteger const& other) const; + [[nodiscard]] bool operator<=(UnsignedBigInteger const& other) const; [[nodiscard]] bool operator>(UnsignedBigInteger const& other) const; [[nodiscard]] bool operator>=(UnsignedBigInteger const& other) const;