diff --git a/src/core/CCNativeint.ml b/src/core/CCNativeint.ml index 065e74fa..66dfa0e7 100644 --- a/src/core/CCNativeint.ml +++ b/src/core/CCNativeint.ml @@ -2,8 +2,13 @@ include Nativeint +[@@@iflt 4.13] + let min : t -> t -> t = Stdlib.min let max : t -> t -> t = Stdlib.max + +[@@@endif] + let hash x = Stdlib.abs (to_int x) let sign i = compare i zero @@ -95,8 +100,7 @@ let random_range i j st = add i (random (sub j i) st) (** {2 Conversion} *) let of_string_exn = of_string -let of_string x = try Some (of_string_exn x) with Failure _ -> None -let of_string_opt = of_string +let of_string = of_string_opt let most_significant_bit = logxor (neg 1n) (shift_right_logical (neg 1n) 1) type output = char -> unit diff --git a/src/core/CCNativeint.mli b/src/core/CCNativeint.mli index 011e128f..16f3a74b 100644 --- a/src/core/CCNativeint.mli +++ b/src/core/CCNativeint.mli @@ -2,14 +2,14 @@ (** Helpers for processor-native integers - This module provides operations on the type [nativeint] of signed 32-bit integers - (on 32-bit platforms) or signed 64-bit integers (on 64-bit platforms). - This integer type has exactly the same width as that of a pointer type in the C compiler. - All arithmetic operations over nativeint are taken modulo 2{^32} or 2{^64} depending + This module provides operations on the type [nativeint] of signed 32-bit integers + (on 32-bit platforms) or signed 64-bit integers (on 64-bit platforms). + This integer type has exactly the same width as that of a pointer type in the C compiler. + All arithmetic operations over nativeint are taken modulo 2{^32} or 2{^64} depending on the word size of the architecture. - Performance notice: values of type [nativeint] occupy more memory space than values of type [int], - and arithmetic operations on [nativeint] are generally slower than those on [int]. + Performance notice: values of type [nativeint] occupy more memory space than values of type [int], + and arithmetic operations on [nativeint] are generally slower than those on [int]. Use [nativeint] only when the application requires the extra bit of precision over the [int] type. @since 2.1 *) @@ -117,7 +117,7 @@ val pp_binary : t printer module Infix : sig val ( + ) : t -> t -> t - (** [x + y] is the sum of [x] and [y]. + (** [x + y] is the sum of [x] and [y]. Addition. *) val ( - ) : t -> t -> t