summaryrefslogtreecommitdiff
path: root/src/util/integer_gmp_imp.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/integer_gmp_imp.h')
-rw-r--r--src/util/integer_gmp_imp.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/util/integer_gmp_imp.h b/src/util/integer_gmp_imp.h
index 176604268..85d49f921 100644
--- a/src/util/integer_gmp_imp.h
+++ b/src/util/integer_gmp_imp.h
@@ -137,6 +137,7 @@ public:
return *this;
}
+
Integer bitwiseOr(const Integer& y) const {
mpz_class result;
mpz_ior(result.get_mpz_t(), d_value.get_mpz_t(), y.d_value.get_mpz_t());
@@ -170,6 +171,24 @@ public:
return Integer( result );
}
+ /**
+ * Returns the Integer obtained by setting the ith bit of the
+ * current Integer to 1.
+ *
+ * @param bit
+ *
+ * @return
+ */
+ Integer setBit(uint32_t i) const {
+ mpz_class res = d_value;
+ mpz_setbit(res.get_mpz_t(), i);
+ return Integer(res);
+ }
+
+ bool isBitSet(uint32_t i) const {
+ return !extractBitRange(1, i).isZero();
+ }
+
/**
* Returns the integer with the binary representation of size bits
* extended with amount 1's
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback