diff options
Diffstat (limited to 'bigint.cpp')
-rw-r--r-- | bigint.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -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; |