1Int(3)                           OCaml library                          Int(3)
2
3
4

NAME

6       Int - Integer values.
7

Module

9       Module   Int
10

Documentation

12       Module Int
13        : sig end
14
15
16       Integer values.
17
18       Integers  are Sys.int_size bits wide and use two's complement represen‐
19       tation. All operations are taken modulo 2^ Sys.int_size . They  do  not
20       fail on overflow.
21
22
23       Since 4.08
24
25
26
27
28
29
30
31   Integers
32       type t = int
33
34
35       The type for integer values.
36
37
38
39       val zero : int
40
41
42       zero is the integer 0 .
43
44
45
46       val one : int
47
48
49       one is the integer 1 .
50
51
52
53       val minus_one : int
54
55
56       minus_one is the integer -1 .
57
58
59
60       val neg : int -> int
61
62
63       neg x is ~-x .
64
65
66
67       val add : int -> int -> int
68
69
70       add x y is the addition x + y .
71
72
73
74       val sub : int -> int -> int
75
76
77       sub x y is the subtraction x - y .
78
79
80
81       val mul : int -> int -> int
82
83
84       mul x y is the multiplication x * y .
85
86
87
88       val div : int -> int -> int
89
90
91       div x y is the division x / y . See (/) for details.
92
93
94
95       val rem : int -> int -> int
96
97
98       rem x y is the remainder x mod y . See (mod) for details.
99
100
101
102       val succ : int -> int
103
104
105       succ x is add x 1 .
106
107
108
109       val pred : int -> int
110
111
112       pred x is sub x 1 .
113
114
115
116       val abs : int -> int
117
118
119       abs x is the absolute value of x . That is x if x is positive and neg x
120       if x is negative. Warning. This may be  negative  if  the  argument  is
121       Int.min_int .
122
123
124
125       val max_int : int
126
127
128       max_int is the greatest representable integer, 2{^[Sys.int_size - 1]} -
129       1 .
130
131
132
133       val min_int : int
134
135
136       min_int is the smallest representable integer, -2{^[Sys.int_size -  1]}
137       .
138
139
140
141       val logand : int -> int -> int
142
143
144       logand x y is the bitwise logical and of x and y .
145
146
147
148       val logor : int -> int -> int
149
150
151       logor x y is the bitwise logical or of x and y .
152
153
154
155       val logxor : int -> int -> int
156
157
158       logxor x y is the bitwise logical exclusive or of x and y .
159
160
161
162       val lognot : int -> int
163
164
165       lognot x is the bitwise logical negation of x .
166
167
168
169       val shift_left : int -> int -> int
170
171
172       shift_left  x  n shifts x to the left by n bits. The result is unspeci‐
173       fied if n < 0 or n > Sys.int_size .
174
175
176
177       val shift_right : int -> int -> int
178
179
180       shift_right x n shifts x to the right by n bits. This is an  arithmetic
181       shift:  the  sign  bit  of  x is replicated and inserted in the vacated
182       bits. The result is unspecified if n < 0 or n > Sys.int_size .
183
184
185
186       val shift_right_logical : int -> int -> int
187
188
189       shift_right x n shifts x to the right by n  bits.  This  is  a  logical
190       shift:  zeroes  are inserted in the vacated bits regardless of the sign
191       of x . The result is unspecified if n < 0 or n > Sys.int_size .
192
193
194
195
196   Predicates and comparisons
197       val equal : int -> int -> bool
198
199
200       equal x y is true if and only if x = y .
201
202
203
204       val compare : int -> int -> int
205
206
207       compare x y is compare x y but more efficient.
208
209
210
211       val min : int -> int -> int
212
213       Return the smaller of the two arguments.
214
215
216       Since 4.13.0
217
218
219
220       val max : int -> int -> int
221
222       Return the greater of the two arguments.
223
224
225       Since 4.13.0
226
227
228
229
230   Converting
231       val to_float : int -> float
232
233
234       to_float x is x as a floating point number.
235
236
237
238       val of_float : float -> int
239
240
241       of_float x truncates x to an integer. The result is unspecified if  the
242       argument is nan or falls outside the range of representable integers.
243
244
245
246       val to_string : int -> string
247
248
249       to_string x is the written representation of x in decimal.
250
251
252
253
254
255OCamldoc                          2022-02-04                            Int(3)
Impressum