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) (Targetint.rem x y) .  If y = 0 , Targetint.rem x y raises  Divi‐
101       sion_by_zero .
102
103
104
105       val unsigned_rem : t -> t -> t
106
107       Same  as  Targetint.rem  ,  except that arguments and result are inter‐
108       preted as     unsigned integers.
109
110
111
112       val succ : t -> t
113
114       Successor.  Targetint.succ x is Targetint.add x Targetint.one .
115
116
117
118       val pred : t -> t
119
120       Predecessor.  Targetint.pred x is Targetint.sub x Targetint.one .
121
122
123
124       val abs : t -> t
125
126       Return the absolute value of its argument.
127
128
129
130       val size : int
131
132       The size in bits of a target native integer.
133
134
135
136       val max_int : t
137
138       The greatest representable target integer, either 2^31 - 1 on a  32-bit
139       platform, or 2^63 - 1 on a 64-bit platform.
140
141
142
143       val min_int : t
144
145       The  smallest  representable  target  integer, either -2^31 on a 32-bit
146       platform, or -2^63 on a 64-bit platform.
147
148
149
150       val logand : t -> t -> t
151
152       Bitwise logical and.
153
154
155
156       val logor : t -> t -> t
157
158       Bitwise logical or.
159
160
161
162       val logxor : t -> t -> t
163
164       Bitwise logical exclusive or.
165
166
167
168       val lognot : t -> t
169
170       Bitwise logical negation.
171
172
173
174       val shift_left : t -> int -> t
175
176
177       Targetint.shift_left x y shifts x to the left by y bits.  The result is
178       unspecified  if y < 0 or y >= bitsize , where bitsize is 32 on a 32-bit
179       platform and 64 on a 64-bit platform.
180
181
182
183       val shift_right : t -> int -> t
184
185
186       Targetint.shift_right x y shifts x to the right by y bits.  This is  an
187       arithmetic  shift:  the sign bit of x is replicated and inserted in the
188       vacated bits.  The result is unspecified if y < 0 or y >= bitsize .
189
190
191
192       val shift_right_logical : t -> int -> t
193
194
195       Targetint.shift_right_logical x y shifts x to  the  right  by  y  bits.
196       This  is  a  logical  shift:  zeroes  are  inserted in the vacated bits
197       regardless of the sign of x .  The result is unspecified if y < 0 or  y
198       >= bitsize .
199
200
201
202       val of_int : int -> t
203
204       Convert  the  given  integer (type int ) to a target integer (type t ),
205       module the target word size.
206
207
208
209       val of_int_exn : int -> t
210
211       Convert the given integer (type int ) to a target integer  (type  t  ).
212       Raises a fatal error if the conversion is not exact.
213
214
215
216       val to_int : t -> int
217
218       Convert  the  given target integer (type t ) to an integer (type int ).
219       The high-order bit is lost during the conversion.
220
221
222
223       val of_float : float -> t
224
225       Convert the given floating-point number to a target integer, discarding
226       the fractional part (truncate towards 0).  The result of the conversion
227       is undefined if, after truncation, the number is outside  the  range  [
228       Targetint.min_int , Targetint.max_int ].
229
230
231
232       val to_float : t -> float
233
234       Convert the given target integer to a floating-point number.
235
236
237
238       val of_int32 : int32 -> t
239
240       Convert the given 32-bit integer (type int32 ) to a target integer.
241
242
243
244       val to_int32 : t -> int32
245
246       Convert the given target integer to a 32-bit integer (type int32 ).  On
247       64-bit platforms, the 64-bit native integer is taken modulo 2^32,  i.e.
248       the  top  32  bits  are  lost.   On 32-bit platforms, the conversion is
249       exact.
250
251
252
253       val of_int64 : int64 -> t
254
255       Convert the given 64-bit integer (type int64 ) to a target integer.
256
257
258
259       val to_int64 : t -> int64
260
261       Convert the given target integer to a 64-bit integer (type int64 ).
262
263
264
265       val of_string : string -> t
266
267       Convert the given string to a target integer.  The string  is  read  in
268       decimal  (by  default) or in hexadecimal, octal or binary if the string
269       begins with 0x , 0o or 0b respectively.  Raise Failure int_of_string if
270       the given string is not a valid representation of an integer, or if the
271       integer represented exceeds the range of integers representable in type
272       nativeint .
273
274
275
276       val to_string : t -> string
277
278       Return the string representation of its argument, in decimal.
279
280
281
282       val compare : t -> t -> int
283
284       The  comparison  function for target integers, with the same specifica‐
285       tion as compare .  Along with the type t , this function compare allows
286       the  module Targetint to be passed as argument to the functors Set.Make
287       and Map.Make .
288
289
290
291       val unsigned_compare : t -> t -> int
292
293       Same as Targetint.compare , except that arguments  are  interpreted  as
294       unsigned integers.
295
296
297
298       val equal : t -> t -> bool
299
300       The equal function for target ints.
301
302
303       type repr =
304        | Int32 of int32
305        | Int64 of int64
306
307
308
309
310
311       val repr : t -> repr
312
313       The concrete representation of a native integer.
314
315
316
317       val print : Format.formatter -> t -> unit
318
319       Print a target integer to a formatter.
320
321
322
323
324
325OCamldoc                          2019-07-30                      Targetint(3)
Impressum