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