diff --git a/README.adoc b/README.adoc index af4584ee..d3f40103 100644 --- a/README.adoc +++ b/README.adoc @@ -116,6 +116,7 @@ Documentation http://cedeela.fr/~simon/software/containers[here]. - `CCHash` (hashing combinators) - `CCError` (monadic error handling, very useful) - `CCIO`, basic utilities for IO (channels, files) +- `CCInt64,` utils for `int64` === Containers.data diff --git a/_oasis b/_oasis index 26c4e732..da751ead 100644 --- a/_oasis +++ b/_oasis @@ -45,7 +45,7 @@ Library "containers" Path: src/core Modules: CCVector, CCPrint, CCError, CCHeap, CCList, CCOpt, CCPair, CCFun, CCHash, CCInt, CCBool, CCFloat, CCArray, CCRef, CCSet, - CCOrd, CCRandom, CCString, CCHashtbl, CCMap, CCFormat, CCIO, + CCOrd, CCRandom, CCString, CCHashtbl, CCMap, CCFormat, CCIO, CCInt64, Containers BuildDepends: bytes # BuildDepends: bytes, bisect_ppx diff --git a/doc/intro.txt b/doc/intro.txt index e372616f..05b4cd88 100644 --- a/doc/intro.txt +++ b/doc/intro.txt @@ -33,6 +33,7 @@ CCHash CCHashtbl CCHeap CCInt +CCInt64 CCIO CCList CCMap diff --git a/src/core/CCInt64.ml b/src/core/CCInt64.ml new file mode 100644 index 00000000..d21c14a8 --- /dev/null +++ b/src/core/CCInt64.ml @@ -0,0 +1,56 @@ + +(* This file is free software, part of containers. See file "license" for more details. *) + +include Int64 + +let (+) = add + +let (-) = sub + +let (~-) = neg + +let ( * ) = mul + +let (/) = div + +let (mod) = rem + +let (land) = logand + +let (lor) = logor + +let (lxor) = logxor + +let lnot = lognot + +let (lsl) = shift_left + +let (lsr) = shift_right_logical + +let (asr) = shift_right + +let equal (x:t) y = x=y + +let hash x = Pervasives.abs (to_int x) + +(** {2 Conversion} *) + +let of_int_exn = of_int + +let of_int x = try Some (of_int_exn x) with Failure _ -> None + +let of_nativeint_exn = of_nativeint + +let of_nativeint x = try Some (of_nativeint_exn x) with Failure _ -> None + +let of_int32_exn = of_int32 + +let of_int32 x = try Some (of_int32_exn x) with Failure _ -> None + +let of_float_exn = of_float + +let of_float x = try Some (of_float_exn x) with Failure _ -> None + +let of_string_exn = of_string + +let of_string x = try Some (of_string_exn x) with Failure _ -> None diff --git a/src/core/CCInt64.mli b/src/core/CCInt64.mli new file mode 100644 index 00000000..9f30e4c0 --- /dev/null +++ b/src/core/CCInt64.mli @@ -0,0 +1,81 @@ + +(* This file is free software, part of containers. See file "license" for more details. *) + +(** {1 Int64} + + Helpers for in64. + + @since NEXT_RELEASE *) + +type t = int64 + +val (+) : t -> t -> t + +val (-) : t -> t -> t + +val (~-) : t -> t + +val ( * ) : t -> t -> t + +val (/) : t -> t -> t + +val (mod) : t -> t -> t + +val abs : t -> t + +val max_int : t + +val min_int : t + +val (land) : t -> t -> t + +val (lor) : t -> t -> t + +val (lxor) : t -> t -> t + +val lnot : t -> t + +val (lsl) : t -> int -> t + +val (lsr) : t -> int -> t + +val (asr) : t -> int -> t + +val equal : t -> t -> bool + +val compare : t -> t -> int + +val hash : t -> int + +(** {2 Conversion} *) + +val to_int : t -> int + +val of_int : int -> t option + +val of_int_exn : int -> t + +val to_int32 : t -> int32 + +val of_int32 : int32 -> t option + +val of_int32_exn : int32 -> t + +val to_nativeint : t -> nativeint + +val of_nativeint : nativeint -> t option + +val of_nativeint_exn : nativeint -> t + +val to_float : t -> float + +val of_float : float -> t option + +val of_float_exn : float -> t + +val to_string : t -> string + +val of_string : string -> t option + +val of_string_exn : string -> t +