summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNicolas "Pixel" Noble <pixel@nobis-crew.org>2013-08-11 18:43:08 +0200
committerNicolas "Pixel" Noble <pixel@nobis-crew.org>2013-08-11 18:43:08 +0200
commitd5a38318b3876bbedffe52ca3b378b03ad4d995a (patch)
tree9aa7022dc9c620f84a2e1798048e0eeebb8e31e5 /src
parenta9e588bd1a90175f411c7bda93969a9bec090af7 (diff)
Forgot the decimal versions of the comparators.
Diffstat (limited to 'src')
-rw-r--r--src/BigInt.cc44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/BigInt.cc b/src/BigInt.cc
index 04d5c1e..0c1b1a5 100644
--- a/src/BigInt.cc
+++ b/src/BigInt.cc
@@ -335,6 +335,20 @@ Balau::BigInt::comp_t Balau::BigInt::comp(const BigInt & a) const throw (General
}
}
+Balau::BigInt::comp_t Balau::BigInt::comp(unsigned int a) const throw (GeneralException) {
+ int r = mp_cmp_d(m_bi, a);
+ switch (r) {
+ case LTC_MP_LT:
+ return LT;
+ case LTC_MP_GT:
+ return GT;
+ case LTC_MP_EQ:
+ return EQ;
+ default:
+ throw GeneralException("Unknown result from mp_cmp_d");
+ }
+}
+
bool Balau::BigInt::operator==(const BigInt & a) const {
comp_t r = comp(a);
return r == EQ;
@@ -365,6 +379,36 @@ bool Balau::BigInt::operator>(const BigInt & a) const {
return r == GT;
}
+bool Balau::BigInt::operator==(unsigned int a) const {
+ comp_t r = comp(a);
+ return r == EQ;
+}
+
+bool Balau::BigInt::operator!=(unsigned int a) const {
+ comp_t r = comp(a);
+ return r != EQ;
+}
+
+bool Balau::BigInt::operator<=(unsigned int a) const {
+ comp_t r = comp(a);
+ return r == LT || r == EQ;
+}
+
+bool Balau::BigInt::operator>=(unsigned int a) const {
+ comp_t r = comp(a);
+ return r == GT || r == EQ;
+}
+
+bool Balau::BigInt::operator<(unsigned int a) const {
+ comp_t r = comp(a);
+ return r == LT;
+}
+
+bool Balau::BigInt::operator>(unsigned int a) const {
+ comp_t r = comp(a);
+ return r == GT;
+}
+
Balau::BigInt Balau::BigInt::modadd(const BigInt & a, const BigInt & m) const throw (GeneralException) {
BigInt r;
if (mp_addmod(m_bi, a.m_bi, m.m_bi, r.m_bi) != CRYPT_OK)