diff --git a/src/core/CCInt.ml b/src/core/CCInt.ml index 1d64460b..dd0ae137 100644 --- a/src/core/CCInt.ml +++ b/src/core/CCInt.ml @@ -71,10 +71,7 @@ let range' i j yield = [5;4;3] (range' 5 2 |> Iter.to_list) *) -let sign i = - if i < 0 then -1 - else if i>0 then 1 - else 0 +let sign i = compare i 0 let neg i = -i diff --git a/src/core/CCInt.mli b/src/core/CCInt.mli index 8cef2434..44ba1a61 100644 --- a/src/core/CCInt.mli +++ b/src/core/CCInt.mli @@ -68,7 +68,8 @@ val hash : t -> int (** [hash x] computes the hash of [x]. *) val sign : t -> int -(** [sign x] is one of [-1, 0, 1]. *) +(** [sign x] return [0] if [x = 0], [-1] if [x < 0] and [1] if [x > 0]. + Same as [compare x 0].*) val neg : t -> t (** [neg x] is [- x].