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