source: Deliverables/D2.2/8051/src/common/intValue.mli @ 486

Last change on this file since 486 was 486, checked in by ayache, 9 years ago

Deliverable D2.2

File size: 2.5 KB
Line 
1
2(** This module defines functions to manipulate integers coded on various number
3    of bits (sized integers). *)
4
5(* Integers, whatever their size, will be represented using the Big_int
6   module. This allows immediate conversion, and allows the representation of
7   any integer (that fits into memory). *)
8
9type int_repr = Big_int.big_int
10
11(* The parameter module. Sized integers are characterized by the number of bits
12   used to represent them, and the fact that they are signed or not. *)
13   
14module type INTTYPE = 
15sig
16  val size      : int (* in bytes *)
17  val is_signed : bool 
18end
19
20(* The signature provided to manipulate sized integers. *)
21
22module type S = sig
23
24  type t = Big_int.big_int
25
26  val compare   : t -> t -> int
27  val to_string : t -> string
28  val zero      : t
29  val one       : t
30
31  val succ   : t -> t
32  val pred   : t -> t
33  val add    : t -> t -> t
34  (** [add_of i1 i2] returns true iff adding the unsigned value of [i1] and the
35      unsigned value of [i2] overflows. *)
36  val add_of : t -> t -> bool
37  val sub    : t -> t -> t
38  (** [sub_of i1 i2] returns true iff substracting the unsigned value of [i1]
39      and the unsigned value of [i2] overflows. *)
40  val sub_of : t -> t -> bool
41  val mul    : t -> t -> t
42  val div    : t -> t -> t
43  val modulo : t -> t -> t
44  val eq     : t -> t -> bool
45  val neq    : t -> t -> bool
46  val lt     : t -> t -> bool
47  val le     : t -> t -> bool
48  val gt     : t -> t -> bool
49  val ge     : t -> t -> bool
50  val neg    : t -> t
51  val lognot : t -> t
52  val logand : t -> t -> t
53  val logor  : t -> t -> t
54  val logxor : t -> t -> t
55  val shl    : t -> t -> t
56  val shr    : t -> t -> t
57  val shrl   : t -> t -> t
58  val max    : t -> t -> t
59  val min    : t -> t -> t
60  val cast   : int_repr -> t
61  val of_int : int -> t
62  val to_int : t -> int
63
64  (** [break i n] cuts [i] in [n] parts. In the resulting list, the first
65      element is the high bits, and the last is the low bits. *)
66  val break : t -> int -> t list
67  (** [merge l] creates the integer where the first element of [l] is its
68      high bits, etc, and the last element of [l] is its low bits. *)
69  val merge : t list -> t
70
71end
72
73(** The functor to create bounded integers from a size and a signedness. *)
74
75module Make: functor (IntType: INTTYPE) -> S
76
77module Int8s   : S
78module Int8u   : S
79module Int16s  : S
80module Int16u  : S
81module Int32   : S
82
83(** Unbounded integers. *)
84module Integer : S
85
86type int8s   = Int8s.t
87type int8u   = Int8u.t
88type int16s  = Int16s.t
89type int16u  = Int16u.t
90type int32   = Int32.t
91type integer = Integer.t
Note: See TracBrowser for help on using the repository browser.