mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:47:34 +00:00
LibCrypto: Add operator>() to UnsignedBigInteger and SignedBigInteger
Piggybacking on operator!=() and operator<().
This commit is contained in:
parent
fda22c6889
commit
89641d90db
4 changed files with 18 additions and 0 deletions
|
@ -202,6 +202,11 @@ bool SignedBigInteger::operator<(const UnsignedBigInteger& other) const
|
||||||
return m_unsigned_data < other;
|
return m_unsigned_data < other;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SignedBigInteger::operator>(const UnsignedBigInteger& other) const
|
||||||
|
{
|
||||||
|
return *this != other && !(*this < other);
|
||||||
|
}
|
||||||
|
|
||||||
FLATTEN SignedBigInteger SignedBigInteger::shift_left(size_t num_bits) const
|
FLATTEN SignedBigInteger SignedBigInteger::shift_left(size_t num_bits) const
|
||||||
{
|
{
|
||||||
return SignedBigInteger { m_unsigned_data.shift_left(num_bits), m_sign };
|
return SignedBigInteger { m_unsigned_data.shift_left(num_bits), m_sign };
|
||||||
|
@ -261,4 +266,9 @@ bool SignedBigInteger::operator<(const SignedBigInteger& other) const
|
||||||
return m_unsigned_data < other.m_unsigned_data;
|
return m_unsigned_data < other.m_unsigned_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SignedBigInteger::operator>(const SignedBigInteger& other) const
|
||||||
|
{
|
||||||
|
return *this != other && !(*this < other);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,10 +121,12 @@ 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 SignedBigInteger& other) const;
|
||||||
|
|
||||||
bool operator==(const UnsignedBigInteger& other) const;
|
bool operator==(const UnsignedBigInteger& other) const;
|
||||||
bool operator!=(const UnsignedBigInteger& other) const;
|
bool operator!=(const UnsignedBigInteger& other) const;
|
||||||
bool operator<(const UnsignedBigInteger& other) const;
|
bool operator<(const UnsignedBigInteger& other) const;
|
||||||
|
bool operator>(const UnsignedBigInteger& other) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_sign { false };
|
bool m_sign { false };
|
||||||
|
|
|
@ -332,6 +332,11 @@ bool UnsignedBigInteger::operator<(const UnsignedBigInteger& other) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool UnsignedBigInteger::operator>(const UnsignedBigInteger& other) const
|
||||||
|
{
|
||||||
|
return *this != other && !(*this < other);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AK::Formatter<Crypto::UnsignedBigInteger>::format(FormatBuilder& fmtbuilder, const Crypto::UnsignedBigInteger& value)
|
void AK::Formatter<Crypto::UnsignedBigInteger>::format(FormatBuilder& fmtbuilder, const Crypto::UnsignedBigInteger& value)
|
||||||
|
|
|
@ -98,6 +98,7 @@ public:
|
||||||
bool operator==(const UnsignedBigInteger& other) const;
|
bool operator==(const UnsignedBigInteger& other) const;
|
||||||
bool operator!=(const UnsignedBigInteger& other) const;
|
bool operator!=(const UnsignedBigInteger& other) const;
|
||||||
bool operator<(const UnsignedBigInteger& other) const;
|
bool operator<(const UnsignedBigInteger& other) const;
|
||||||
|
bool operator>(const UnsignedBigInteger& other) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class UnsignedBigIntegerAlgorithms;
|
friend class UnsignedBigIntegerAlgorithms;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue