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

NAME

6       Int32 - 32-bit integers.
7

Module

9       Module   Int32
10

Documentation

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