File tree 1 file changed +10
-6
lines changed
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 =
5
5
n land lnot m
6
6
7
7
let 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)
14
18
15
19
let ceil_pow_2 n =
16
20
if n < = 1 then 1
You can’t perform that action at this time.
0 commit comments