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

NAME

6       Targetint - Target processor-native integers.
7

Module

9       Module   Targetint
10

Documentation

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