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