From 53a114b1704b0833c2d99c8d0e4ba4fcb6ed09c1 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Thu, 17 Nov 2022 00:32:42 +0700 Subject: BigInteger implements IComparable --- crypto/src/math/BigInteger.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'crypto') diff --git a/crypto/src/math/BigInteger.cs b/crypto/src/math/BigInteger.cs index c8581775d..5b2ea0d87 100644 --- a/crypto/src/math/BigInteger.cs +++ b/crypto/src/math/BigInteger.cs @@ -16,7 +16,7 @@ namespace Org.BouncyCastle.Math { [Serializable] public sealed class BigInteger - : IComparable, IEquatable + : IComparable, IComparable, IEquatable { // The first few odd primes /* @@ -1051,6 +1051,17 @@ namespace Org.BouncyCastle.Math return sign > 0 && nBits == 1; } + public int CompareTo(object obj) + { + if (obj == null) + return 1; + + if (!(obj is BigInteger other)) + throw new ArgumentException("Object is not a BigInteger", nameof(obj)); + + return CompareTo(other); + } + public int CompareTo(BigInteger other) { if (other == null) -- cgit 1.5.1