mirror of
https://github.com/logos-storage/logos-storage-proofs-circuits.git
synced 2026-01-02 13:33:07 +00:00
18 lines
476 B
Haskell
18 lines
476 B
Haskell
|
|
module Misc where
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
import Data.Bits
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
-- | Smallest integer @k@ such that @2^k@ is larger or equal to @n@
|
|
ceilingLog2 :: Integer -> Int
|
|
ceilingLog2 0 = 0
|
|
ceilingLog2 n = 1 + go (n-1) where
|
|
go 0 = -1
|
|
go k = 1 + go (shiftR k 1)
|
|
|
|
--------------------------------------------------------------------------------
|