From ff6ca0f02da0e3acf22a3be1a3f41299935e5a87 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Sun, 18 Jul 2021 23:20:39 +0300 Subject: [PATCH] LibCrypto: Add operator<= and operator>= to SignedBigInteger --- .../Libraries/LibCrypto/BigInt/SignedBigInteger.cpp | 10 ++++++++++ Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.cpp b/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.cpp index 8c6de49b61..3d6bdffa55 100644 --- a/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.cpp +++ b/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.cpp @@ -280,9 +280,19 @@ bool SignedBigInteger::operator<(const SignedBigInteger& other) const return m_unsigned_data < other.m_unsigned_data; } +bool SignedBigInteger::operator<=(const SignedBigInteger& other) const +{ + return *this < other || *this == other; +} + bool SignedBigInteger::operator>(const SignedBigInteger& other) const { return *this != other && !(*this < other); } +bool SignedBigInteger::operator>=(const SignedBigInteger& other) const +{ + return !(*this < other); +} + } diff --git a/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.h b/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.h index b3adcdb8bb..099348bfd7 100644 --- a/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.h +++ b/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.h @@ -121,7 +121,9 @@ public: bool operator==(const SignedBigInteger& other) const; bool operator!=(const SignedBigInteger& other) const; bool operator<(const SignedBigInteger& other) const; + bool operator<=(const SignedBigInteger& other) const; bool operator>(const SignedBigInteger& other) const; + bool operator>=(const SignedBigInteger& other) const; bool operator==(const UnsignedBigInteger& other) const; bool operator!=(const UnsignedBigInteger& other) const;