summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/sail_lib.ml7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/sail_lib.ml b/src/sail_lib.ml
index 2e00f980..76c2f59b 100644
--- a/src/sail_lib.ml
+++ b/src/sail_lib.ml
@@ -138,6 +138,13 @@ let rec take n xs =
| n, (x :: xs) -> x :: take (n - 1) xs
| n, [] -> []
+let count_leading_zeros xs =
+ let rec clz = function
+ | [] -> 0
+ | (B1 :: xs') -> clz xs'
+ | (B0 :: xs') -> 1 + clz xs' in
+ Big_int.of_int (clz xs)
+
let subrange (list, n, m) =
let n = Big_int.to_int n in
let m = Big_int.to_int m in