File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -5,12 +5,16 @@ let max_0 n =
55 n land lnot m
66
77let ceil_pow_2_minus_1 n =
8- let n = n lor (n lsr 1 ) in
9- let n = n lor (n lsr 2 ) in
10- let n = n lor (n lsr 4 ) in
11- let n = n lor (n lsr 8 ) in
12- let n = n lor (n lsr 16 ) in
13- if Sys. int_size > 32 then n lor (n lsr 32 ) else n
8+ let n = Nativeint. of_int n in
9+ let n = Nativeint. logor n (Nativeint. shift_right_logical n 1 ) in
10+ let n = Nativeint. logor n (Nativeint. shift_right_logical n 2 ) in
11+ let n = Nativeint. logor n (Nativeint. shift_right_logical n 4 ) in
12+ let n = Nativeint. logor n (Nativeint. shift_right_logical n 8 ) in
13+ let n = Nativeint. logor n (Nativeint. shift_right_logical n 16 ) in
14+ Nativeint. to_int
15+ (if Sys. int_size > 32 then
16+ Nativeint. logor n (Nativeint. shift_right_logical n 32 )
17+ else n)
1418
1519let ceil_pow_2 n =
1620 if n < = 1 then 1
You can’t perform that action at this time.
0 commit comments