From b06155f05bd184e81d87a53dc1130e94a0da3964 Mon Sep 17 00:00:00 2001 From: Fardale Date: Mon, 18 May 2020 22:25:20 +0200 Subject: [PATCH] implement CCInt.sign using CCInt.compare and add more doc --- src/core/CCInt.ml | 5 +---- src/core/CCInt.mli | 3 ++- 2 files changed, 3 insertions(+), 5 deletions(-) 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].