1Stdlib.Int32(3) OCaml library Stdlib.Int32(3)
2
3
4
6 Stdlib.Int32 - no description
7
9 Module Stdlib.Int32
10
12 Module Int32
13 : (module Stdlib__Int32)
14
15
16
17
18
19
20
21
22 val zero : int32
23
24 The 32-bit integer 0.
25
26
27
28 val one : int32
29
30 The 32-bit integer 1.
31
32
33
34 val minus_one : int32
35
36 The 32-bit integer -1.
37
38
39
40 val neg : int32 -> int32
41
42 Unary negation.
43
44
45
46 val add : int32 -> int32 -> int32
47
48 Addition.
49
50
51
52 val sub : int32 -> int32 -> int32
53
54 Subtraction.
55
56
57
58 val mul : int32 -> int32 -> int32
59
60 Multiplication.
61
62
63
64 val div : int32 -> int32 -> int32
65
66 Integer division. This division rounds the real quotient of its argu‐
67 ments towards zero, as specified for (/) .
68
69
70 Raises Division_by_zero if the second argument is zero.
71
72
73
74 val unsigned_div : int32 -> int32 -> int32
75
76 Same as Int32.div , except that arguments and result are interpreted as
77 unsigned 32-bit integers.
78
79
80 Since 4.08.0
81
82
83
84 val rem : int32 -> int32 -> int32
85
86 Integer remainder. If y is not zero, the result of Int32.rem x y sat‐
87 isfies the following property: x = Int32.add (Int32.mul (Int32.div x y)
88 y) (Int32.rem x y) . If y = 0 , Int32.rem x y raises Division_by_zero
89 .
90
91
92
93 val unsigned_rem : int32 -> int32 -> int32
94
95 Same as Int32.rem , except that arguments and result are interpreted as
96 unsigned 32-bit integers.
97
98
99 Since 4.08.0
100
101
102
103 val succ : int32 -> int32
104
105 Successor. Int32.succ x is Int32.add x Int32.one .
106
107
108
109 val pred : int32 -> int32
110
111 Predecessor. Int32.pred x is Int32.sub x Int32.one .
112
113
114
115 val abs : int32 -> int32
116
117
118 abs x is the absolute value of x . On min_int this is min_int itself
119 and thus remains negative.
120
121
122
123 val max_int : int32
124
125 The greatest representable 32-bit integer, 2^31 - 1.
126
127
128
129 val min_int : int32
130
131 The smallest representable 32-bit integer, -2^31.
132
133
134
135 val logand : int32 -> int32 -> int32
136
137 Bitwise logical and.
138
139
140
141 val logor : int32 -> int32 -> int32
142
143 Bitwise logical or.
144
145
146
147 val logxor : int32 -> int32 -> int32
148
149 Bitwise logical exclusive or.
150
151
152
153 val lognot : int32 -> int32
154
155 Bitwise logical negation.
156
157
158
159 val shift_left : int32 -> int -> int32
160
161
162 Int32.shift_left x y shifts x to the left by y bits. The result is un‐
163 specified if y < 0 or y >= 32 .
164
165
166
167 val shift_right : int32 -> int -> int32
168
169
170 Int32.shift_right x y shifts x to the right by y bits. This is an
171 arithmetic shift: the sign bit of x is replicated and inserted in the
172 vacated bits. The result is unspecified if y < 0 or y >= 32 .
173
174
175
176 val shift_right_logical : int32 -> int -> int32
177
178
179 Int32.shift_right_logical x y shifts x to the right by y bits. This is
180 a logical shift: zeroes are inserted in the vacated bits regardless of
181 the sign of x . The result is unspecified if y < 0 or y >= 32 .
182
183
184
185 val of_int : int -> int32
186
187 Convert the given integer (type int ) to a 32-bit integer (type int32
188 ). On 64-bit platforms, the argument is taken modulo 2^32.
189
190
191
192 val to_int : int32 -> int
193
194 Convert the given 32-bit integer (type int32 ) to an integer (type int
195 ). On 32-bit platforms, the 32-bit integer is taken modulo 2^31, i.e.
196 the high-order bit is lost during the conversion. On 64-bit platforms,
197 the conversion is exact.
198
199
200
201 val unsigned_to_int : int32 -> int option
202
203 Same as Int32.to_int , but interprets the argument as an unsigned inte‐
204 ger. Returns None if the unsigned value of the argument cannot fit
205 into an int .
206
207
208 Since 4.08.0
209
210
211
212 val of_float : float -> int32
213
214 Convert the given floating-point number to a 32-bit integer, discarding
215 the fractional part (truncate towards 0). If the truncated float‐
216 ing-point number is outside the range [ Int32.min_int , Int32.max_int
217 ], no exception is raised, and an unspecified, platform-dependent inte‐
218 ger is returned.
219
220
221
222 val to_float : int32 -> float
223
224 Convert the given 32-bit integer to a floating-point number.
225
226
227
228 val of_string : string -> int32
229
230 Convert the given string to a 32-bit integer. The string is read in
231 decimal (by default, or if the string begins with 0u ) or in hexadeci‐
232 mal, octal or binary if the string begins with 0x , 0o or 0b respec‐
233 tively.
234
235 The 0u prefix reads the input as an unsigned integer in the range [0,
236 2*Int32.max_int+1] . If the input exceeds Int32.max_int it is con‐
237 verted to the signed integer Int32.min_int + input - Int32.max_int - 1
238 .
239
240 The _ (underscore) character can appear anywhere in the string and is
241 ignored.
242
243
244 Raises Failure if the given string is not a valid representation of an
245 integer, or if the integer represented exceeds the range of integers
246 representable in type int32 .
247
248
249
250 val of_string_opt : string -> int32 option
251
252 Same as of_string , but return None instead of raising.
253
254
255 Since 4.05
256
257
258
259 val to_string : int32 -> string
260
261 Return the string representation of its argument, in signed decimal.
262
263
264
265 val bits_of_float : float -> int32
266
267 Return the internal representation of the given float according to the
268 IEEE 754 floating-point 'single format' bit layout. Bit 31 of the re‐
269 sult represents the sign of the float; bits 30 to 23 represent the (bi‐
270 ased) exponent; bits 22 to 0 represent the mantissa.
271
272
273
274 val float_of_bits : int32 -> float
275
276 Return the floating-point number whose internal representation, accord‐
277 ing to the IEEE 754 floating-point 'single format' bit layout, is the
278 given int32 .
279
280
281 type t = int32
282
283
284 An alias for the type of 32-bit integers.
285
286
287
288 val compare : t -> t -> int
289
290 The comparison function for 32-bit integers, with the same specifica‐
291 tion as compare . Along with the type t , this function compare allows
292 the module Int32 to be passed as argument to the functors Set.Make and
293 Map.Make .
294
295
296
297 val unsigned_compare : t -> t -> int
298
299 Same as Int32.compare , except that arguments are interpreted as un‐
300 signed 32-bit integers.
301
302
303 Since 4.08.0
304
305
306
307 val equal : t -> t -> bool
308
309 The equal function for int32s.
310
311
312 Since 4.03.0
313
314
315
316 val min : t -> t -> t
317
318 Return the smaller of the two arguments.
319
320
321 Since 4.13.0
322
323
324
325 val max : t -> t -> t
326
327 Return the greater of the two arguments.
328
329
330 Since 4.13.0
331
332
333
334
335
336OCamldoc 2023-07-20 Stdlib.Int32(3)