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