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