4
let unsigned_compare i j =
5
compare (sub i min_int) (sub j min_int)
8
let max_int = of_int Stdcompat__pervasives.max_int in
10
if compare zero i <= 0 && compare i max_int <= 0 then
15
(* Unsigned division from signed division of the same
16
bitness. See Warren Jr., Henry S. (2013). Hacker's Delight (2 ed.), Sec 9-3.
18
let unsigned_div n d =
20
if unsigned_compare n d < 0 then zero else one
22
let q = shift_left (div (shift_right_logical n 1) d) 1 in
23
let r = sub n (mul q d) in
24
if unsigned_compare r d >= 0 then succ q else q
26
let unsigned_rem n d =
27
sub n (mul (unsigned_div n d) d)
31
let equal : t -> t -> bool = ( = )
36
Stdcompat__tools.option_fail of_string s