implement CCInt.sign using CCInt.compare and add more doc

This commit is contained in:
Fardale 2020-05-18 22:25:20 +02:00
parent eaa421c62d
commit b06155f05b
2 changed files with 3 additions and 5 deletions

View file

@ -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

View file

@ -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].