diff options
Diffstat (limited to 'ethutil/big.go')
-rw-r--r-- | ethutil/big.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/ethutil/big.go b/ethutil/big.go index 07d1386e1..2ff1c72d8 100644 --- a/ethutil/big.go +++ b/ethutil/big.go @@ -62,6 +62,16 @@ func S256(x *big.Int) *big.Int { } } +func FirstBitSet(v *big.Int) int { + for i := 0; i < v.BitLen(); i++ { + if v.Bit(i) > 0 { + return i + } + } + + return v.BitLen() +} + // Big to bytes // // Returns the bytes of a big integer with the size specified by **base** |