aboutsummaryrefslogtreecommitdiff
path: root/bigint.cpp
diff options
context:
space:
mode:
authorTom Smeding <hallo@tomsmeding.nl>2016-10-24 14:22:24 +0200
committertomsmeding <tom.smeding@gmail.com>2016-10-24 19:33:53 +0200
commit7cca53ede2ee4900fce30334fb561a24d1b5d2de (patch)
tree50ab1737c28d718efa672caef8c1c82ff47475e9 /bigint.cpp
parentdf6c0e07bc74a4137ccb8719a28f58b50ba946c6 (diff)
ACTUALLY fix strongPseudoPrime2
Diffstat (limited to 'bigint.cpp')
-rw-r--r--bigint.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/bigint.cpp b/bigint.cpp
index 0d2a72b..83d00c1 100644
--- a/bigint.cpp
+++ b/bigint.cpp
@@ -542,6 +542,16 @@ bool Bigint::odd() const {
return !even();
}
+int Bigint::trailingZeros() const {
+ if(digits.size()==0)throw domain_error("trailingZeros called on zero bigint");
+ int res=0;
+ for(digit_t dig : digits){
+ if(dig==0)res+=digit_bits;
+ else return res+__builtin_ctz(dig);
+ }
+ assert(false); //bigint is not consistent: zero while digits is not empty!
+}
+
//Produces a string with the bytes of the mantissa in little-endian order.
string Bigint::serialiseMantissa() const {
string s;