(** {2 Operators}
- It is recommended to do [open Int63.Operators] in your code
- so that you get the operators [+^], [-^] .. and the type [int63]
- directly, and can still use the less frequent functions
- as [Int63.logand] etc.
+ It is recommended to do:
+
+{[
+open Int63.Operators
+]}
+
+ in your code so that you get the operators [+^], [-^] .. and the
+ type [int63] directly, and can still use the less frequent
+ functions as {!Int63.logand} etc.
*)
module Operators : sig
type int63 = t
+ (* For the gory details of the rules of operators, see:
+ * http://caml.inria.fr/pub/docs/manual-ocaml/lex.html
+ *)
+
val ( +^ ) : t -> t -> t
val ( -^ ) : t -> t -> t
val ( *^ ) : t -> t -> t
val ( /^ ) : t -> t -> t
- (** Arithmetic operators. *)
+ val ( %^ ) : t -> t -> t
+ (** Infix arithmetic operators. eg. [a +^ b -^ c] *)
+
+ val ( <^< ) : t -> int -> t
+ val ( >^> ) : t -> int -> t
+ (** Infix shift left and logical shift right.
+ eg. [~^1 <^< 62]
+
+ NB: We cannot use two less-than signs or two greater-than signs
+ in a row because that clashes with the symbols used for
+ camlp4 quotations. *)
- val ( <<^ ) : t -> int -> t
- val ( >>^ ) : t -> int -> t
- (** Shift left and logical shift right. *)
+ val ( &&^ ) : t -> t -> t
+ val ( ||^ ) : t -> t -> t
+ val ( ^^^ ) : t -> t -> t
+ (** Infix logical and, or and xor operators.
+ eg. [bits &&^ mask] *)
val ( ~^ ) : int -> t
- (** Constant, eg. [~^0] is the constant zero. *)
+ (** Small integer constants,
+ eg. [~^0] is the constant zero and [~^1] is the constant one. *)
val ( ~^~ ) : int -> t
- (** Negative constant, eg. [~^~1] is the constant minus one. *)
+ (** Small negative integer constants,
+ eg. [~^~1] is the constant minus one. *)
end
(** {2 Functions}
(** Absolute value. *)
val max_int : t
- (** The constant [2{^62}-1]. *)
+ (** The constant 2{^62}-1. *)
val min_int : t
- (** The constant [-2{^62}]. *)
+ (** The constant -2{^62}. *)
val logand : t -> t -> t
val logor : t -> t -> t