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

NAME

6       Nativeint - Processor-native integers.
7

Module

9       Module   Nativeint
10

Documentation

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