(* 32-bit integers.
*
* (C) 1997 Jean-Christophe FILLIATRE.
*
* This library is completely free, but comes with no warranty. *)
(* $Id: int32.mli,v 1.3 1997/05/22 07:53:02 jcfillia Exp $ *)
type int32 (* abstract type of 32-bit integers *)
(* conversions with type int *)
external of_int : int -> int32 = "int32_of_int"
val int32_of_int : int -> int32
(* Conversion from type [int] to type [int32]. *)
external to_int : int32 -> int = "int32_to_int"
val int_of_int32 : int32 -> int
(* Conversion from type [int32] to type [int]. *)
external string_of_int32 : int32 -> string = "int32_to_string"
(* comparison *)
external eq : int32 -> int32 -> bool = "int32_eq"
external lt : int32 -> int32 -> bool = "int32_lt"
external le : int32 -> int32 -> bool = "int32_le"
external gt : int32 -> int32 -> bool = "int32_gt"
external ge : int32 -> int32 -> bool = "int32_ge"
(* Self explanatory. *)
val min : int32 -> int32 -> int32
val max : int32 -> int32 -> int32
(* limits *)
val max_int32 : int32
val min_int32 : int32
(* arithmetic *)
external neg : int32 -> int32 = "int32_neg"
(* Unary negation. *)
external abs : int32 -> int32 = "int32_abs"
(* Return the absolute value of the argument. *)
external succ : int32 -> int32 = "int32_succ"
(* [succ x] is [x+1]. *)
external pred : int32 -> int32 = "int32_pred"
(* [pred x] is [x-1]. *)
external add : int32 -> int32 -> int32 = "int32_add"
(* Integer addition. *)
external sub : int32 -> int32 -> int32 = "int32_sub"
(* Integer subtraction. *)
external mul : int32 -> int32 -> int32 = "int32_mul"
(* Integer multiplication. *)
val div : int32 -> int32 -> int32
val modulo : int32 -> int32 -> int32
(* Integer division and remainder.
Raise [Division_by_zero] if the second argument is 0.
If one of the arguments is negative, the result is
platform-dependent. *)
(* bitwise operations *)
external (land) : int32 -> int32 -> int32 = "int32_land"
(* Bitwise logical and. *)
external (lor) : int32 -> int32 -> int32 = "int32_lor"
(* Bitwise logical or. *)
external (lxor) : int32 -> int32 -> int32 = "int32_lxor"
(* Bitwise logical exclusive or. *)
val lnot: int32 -> int32
(* Bitwise logical negation. *)
external (lsl) : int32 -> int -> int32 = "int32_lsl"
(* [n lsl m] shifts [n] to the left by [m] bits. *)
external (lsr) : int32 -> int -> int32 = "int32_lsr"
(* [n lsr m] shifts [n] to the right by [m] bits.
This is a logical shift: zeroes are inserted regardless of
the sign of [n], that is considering [n] as an unsigned
32-bit integer. *)
external (asr) : int32 -> int -> int32 = "int32_asr"
(* [n asr m] shifts [n] to the right by [m] bits.
This is an arithmetic shift: the sign bit of [n] is replicated. *)