File tree Expand file tree Collapse file tree 1 file changed +2
-12
lines changed Expand file tree Collapse file tree 1 file changed +2
-12
lines changed Original file line number Diff line number Diff line change 88
88
89
89
let (lsr ) = shift_right_logical
90
90
91
- let clz v =
92
- let n = ref @@ of_int 64 and x = ref v and y = ref zero in
93
- y := ! x lsr 32 ; if ! y <> zero then (n := ! n - of_int 32 ; x := ! y);
94
- y := ! x lsr 16 ; if ! y <> zero then (n := ! n - of_int 16 ; x := ! y);
95
- y := ! x lsr 8 ; if ! y <> zero then (n := ! n - of_int 8 ; x := ! y);
96
- y := ! x lsr 4 ; if ! y <> zero then (n := ! n - of_int 4 ; x := ! y);
97
- y := ! x lsr 2 ; if ! y <> zero then (n := ! n - of_int 2 ; x := ! y);
98
- y := ! x lsr 1 ; if ! y <> zero then ! n - of_int 2
99
- else ! n - ! x
100
- [@@ inline]
101
-
102
- let numbits v = of_int 64 - clz v [@@ inline]
91
+ let clz v = of_int (clz v) [@@ inline]
103
92
93
+ let numbits v = of_int 63 - clz v [@@ inline]
104
94
105
95
let highest_bit x = numbits x - one
106
96
let is_zero ~bit x = x land (one lsl to_int bit) = zero
You can’t perform that action at this time.
0 commit comments