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