diff --git a/src/core/CCInt.ml b/src/core/CCInt.ml index a2efe7bc..7cf914c8 100644 --- a/src/core/CCInt.ml +++ b/src/core/CCInt.ml @@ -2,24 +2,8 @@ include Int -type t = int type 'a iter = ('a -> unit) -> unit -let zero = 0 -let one = 1 -let minus_one = -1 -let add = ( + ) -let sub = ( - ) -let mul = ( * ) -let div = ( / ) -let succ = succ -let pred = pred -let abs = abs -let max_int = max_int -let min_int = min_int -let equal (a : int) b = Stdlib.( = ) a b -let compare (a : int) b = compare a b - (* use FNV: https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function *) let hash (n : int) : int = @@ -65,7 +49,6 @@ let range' i j yield = range i (j + 1) yield let sign i = compare i 0 -let neg i = -i let pow a b = let rec aux acc = function @@ -147,11 +130,8 @@ let random_small = random 100 let random_range i j st = i + random (j - i) st let pp fmt = Format.pp_print_int fmt let most_significant_bit = -1 lxor (-1 lsr 1) -let to_string = string_of_int let of_string s = try Some (int_of_string s) with Failure _ -> None let of_string_exn = Stdlib.int_of_string -let to_float = float_of_int -let of_float = int_of_float type output = char -> unit @@ -248,11 +228,3 @@ let popcount (b : int) : int = let b = add b (shift_right_logical b 32) in let b = logand b 0x7fL in to_int b - -let logand = ( land ) -let logor = ( lor ) -let logxor = ( lxor ) -let lognot = lnot -let shift_left = ( lsl ) -let shift_right = ( asr ) -let shift_right_logical = ( lsr ) diff --git a/src/core/CCInt.mli b/src/core/CCInt.mli index 65b01ef1..fb12bb90 100644 --- a/src/core/CCInt.mli +++ b/src/core/CCInt.mli @@ -5,65 +5,6 @@ include module type of Int (** @inline *) -type t = int - -val zero : t -(** [zero] is the integer [0]. - @since 3.0 *) - -val one : t -(** [one] is the integer [1]. - @since 3.0 *) - -val minus_one : t -(** [minus_one] is the integer [-1]. - @since 3.0 *) - -val add : t -> t -> t -(** [add x y] is [x + y]. - @since 3.0 *) - -val sub : t -> t -> t -(** [sub x y] is [x - y]. - @since 3.0 *) - -val mul : t -> t -> t -(** [mul x y] is [x * y]. - @since 3.0 *) - -val div : t -> t -> t -(** [div x y] is [x / y] - @since 3.0 *) - -val succ : t -> t -(** [succ x] is [x + 1]. - @since 3.0 *) - -val pred : t -> t -(** [pred x] is [x - 1]. - @since 3.0 *) - -val abs : t -> t -(** [abs x] is the absolute value of [x]. It is [x] if [x] is positive - and [neg x] otherwise. - @since 3.0 *) - -val max_int : t -(** [max_int] is the maximum integer. - @since 3.0 *) - -val min_int : t -(** [min_int] is the minimum integer. - @since 3.0 *) - -val compare : t -> t -> int -(** [compare x y] is the comparison function for integers - with the same specification as {!Stdlib.compare}. *) - -val equal : t -> t -> bool -(** [equal x y] is [true] iff [x] and [y] are equal. - Equality function for integers. *) - val hash : t -> int (** [hash x] computes the hash of [x]. *) @@ -71,11 +12,6 @@ val sign : t -> int (** [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]. - Unary negation. - @since 0.5 *) - val pow : t -> t -> t (** [pow base exponent] returns [base] raised to the power of [exponent]. [pow x y = x^y] for positive integers [x] and [y]. @@ -103,22 +39,6 @@ val random_range : int -> int -> t random_gen val pp : t printer (** [pp ppf x] prints the integer [x] on [ppf]. *) -val to_float : t -> float -(** [to_float] is the same as [float_of_int] - @since 3.0*) - -[@@@ocaml.warning "-32"] - -val of_float : float -> t -(** [to_float] is the same as [int_of_float] - @since 3.0*) - -[@@@ocaml.warning "+32"] - -val to_string : t -> string -(** [to_string x] returns the string representation of the integer [x], in signed decimal. - @since 0.13 *) - val of_string : string -> t option (** [of_string s] converts the given string [s] into an integer. Safe version of {!of_string_exn}. @@ -130,11 +50,6 @@ val of_string_exn : string -> t @raise Failure in case of failure. @since 3.0 *) -val of_float : float -> t -(** [of_float x] converts the given floating-point number [x] to an integer. - Alias to {!int_of_float}. - @since 3.0 *) - val pp_binary : t printer (** [pp_binary ppf x] prints [x] on [ppf]. Print as "0b00101010". @@ -173,34 +88,6 @@ val popcount : t -> int (** Number of bits set to 1 @since 3.0 *) -val logand : t -> t -> t -(** [logand] is the same as [(land)]. - @since 3.0 *) - -val logor : t -> t -> t -(** [logand] is the same as [(lor)]. - @since 3.0 *) - -val logxor : t -> t -> t -(** [logxor] is the same as [(lxor)]. - @since 3.0 *) - -val lognot : t -> t -(** [logand] is the same as [lnot]. - @since 3.0 *) - -val shift_left : t -> int -> t -(** [shift_left] is the same as [(lsl)]. - @since 3.0 *) - -val shift_right : t -> int -> t -(** [shift_right] is the same as [(asr)]. - @since 3.0 *) - -val shift_right_logical : t -> int -> t -(** [shift_right_logical] is the same as [(lsr)]. - @since 3.0 *) - (** {2 Infix Operators} @since 0.17 *)