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