@@ -313,13 +313,13 @@ struct
313313 | Some x , Some y -> (try of_int ik (f x y) with Division_by_zero | Invalid_argument _ -> (top_of ik,{overflow= false ; underflow= false }))
314314 | _ , _ -> (top_of ik,{overflow= false ; underflow= false })
315315
316- let min_val_bit_constrained n =
317- if Ints_t. equal n Ints_t. zero then
318- Ints_t. neg Ints_t. one
319- else
320- Ints_t. neg @@ Ints_t. shift_left Ints_t. one (Z. numbits (Z. sub (Z. abs @@ Ints_t. to_bigint n) Z. one))
316+ let min_val_bit_constrained n =
317+ if Ints_t. equal n Ints_t. zero then
318+ Ints_t. neg Ints_t. one
319+ else
320+ Ints_t. neg @@ Ints_t. shift_left Ints_t. one (Z. numbits (Z. pred (Z. abs @@ Ints_t. to_bigint n)))
321321
322- let max_val_bit_constrained n =
322+ let max_val_bit_constrained n =
323323 let x = if Ints_t. compare n Ints_t. zero < 0 then Ints_t. sub (Ints_t. neg n) Ints_t. one else n in
324324 Ints_t. sub (Ints_t. shift_left Ints_t. one (Z. numbits @@ Z. abs @@ Ints_t. to_bigint x)) Ints_t. one
325325
@@ -374,13 +374,13 @@ struct
374374 let upper = max_val_bit_constrained @@ Ints_t. min x1 y1 in
375375 of_interval ik (Ints_t. zero, upper) |> fst
376376 | true , _ , _ , false | _ , false , true , _ ->
377- let lower = List. fold_left Ints_t. min Ints_t. zero
378- (List. append (List. map min_val_bit_constrained [x1; y1])
379- (List. map (fun i -> Ints_t. neg @@ Ints_t. add (max_val_bit_constrained i) Ints_t. one) [x2; y2])) in
377+ let lower = List. fold_left Ints_t. min Ints_t. zero
378+ (List. append (List. map min_val_bit_constrained [x1; y1])
379+ (List. map (fun i -> Ints_t. neg @@ Ints_t. add (max_val_bit_constrained i) Ints_t. one) [x2; y2])) in
380380 of_interval ik (lower, Ints_t. zero) |> fst
381- | _ -> let lower = List. fold_left Ints_t. min Ints_t. zero
382- (List. append (List. map min_val_bit_constrained [x1; y1])
383- (List. map (fun i -> Ints_t. neg @@ Ints_t. add (max_val_bit_constrained i) Ints_t. one) [x2; y2])) in
381+ | _ -> let lower = List. fold_left Ints_t. min Ints_t. zero
382+ (List. append (List. map min_val_bit_constrained [x1; y1])
383+ (List. map (fun i -> Ints_t. neg @@ Ints_t. add (max_val_bit_constrained i) Ints_t. one) [x2; y2])) in
384384 let upper = List. fold_left Ints_t. max Ints_t. zero (List. map max_val_bit_constrained [x1;x2;y1;y2]) in
385385 of_interval ik (lower, upper) |> fst
386386
0 commit comments