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

NAME

6       Nativeint - Processor-native integers.
7

Module

9       Module   Nativeint
10

Documentation

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