1Stdlib.Int(3) OCaml library Stdlib.Int(3)
2
3
4
6 Stdlib.Int - no description
7
9 Module Stdlib.Int
10
12 Module Int
13 : (module Stdlib__int)
14
15
16
17
18
19
20
21
22
23 Integers
24 type t = int
25
26
27 The type for integer values.
28
29
30
31 val zero : int
32
33
34 zero is the integer 0 .
35
36
37
38 val one : int
39
40
41 one is the integer 1 .
42
43
44
45 val minus_one : int
46
47
48 minus_one is the integer -1 .
49
50
51
52 val neg : int -> int
53
54
55 neg x is ~-x .
56
57
58
59 val add : int -> int -> int
60
61
62 add x y is the addition x + y .
63
64
65
66 val sub : int -> int -> int
67
68
69 sub x y is the subtraction x - y .
70
71
72
73 val mul : int -> int -> int
74
75
76 mul x y is the multiplication x * y .
77
78
79
80 val div : int -> int -> int
81
82
83 div x y is the division x / y . See (/) for details.
84
85
86
87 val rem : int -> int -> int
88
89
90 rem x y is the remainder x mod y . See (mod) for details.
91
92
93
94 val succ : int -> int
95
96
97 succ x is add x 1 .
98
99
100
101 val pred : int -> int
102
103
104 pred x is sub x 1 .
105
106
107
108 val abs : int -> int
109
110
111 abs x is the absolute value of x . That is x if x is positive and neg x
112 if x is negative. Warning. This may be negative if the argument is
113 Int.min_int .
114
115
116
117 val max_int : int
118
119
120 max_int is the greatest representable integer, 2{^[Sys.int_size - 1]} -
121 1 .
122
123
124
125 val min_int : int
126
127
128 min_int is the smallest representable integer, -2{^[Sys.int_size - 1]}
129 .
130
131
132
133 val logand : int -> int -> int
134
135
136 logand x y is the bitwise logical and of x and y .
137
138
139
140 val logor : int -> int -> int
141
142
143 logor x y is the bitwise logical or of x and y .
144
145
146
147 val logxor : int -> int -> int
148
149
150 logxor x y is the bitwise logical exclusive or of x and y .
151
152
153
154 val lognot : int -> int
155
156
157 lognot x is the bitwise logical negation of x .
158
159
160
161 val shift_left : int -> int -> int
162
163
164 shift_left x n shifts x to the left by n bits. The result is unspeciā
165 fied if n < 0 or n > Sys.int_size .
166
167
168
169 val shift_right : int -> int -> int
170
171
172 shift_right x n shifts x to the right by n bits. This is an arithmetic
173 shift: the sign bit of x is replicated and inserted in the vacated
174 bits. The result is unspecified if n < 0 or n > Sys.int_size .
175
176
177
178 val shift_right_logical : int -> int -> int
179
180
181 shift_right x n shifts x to the right by n bits. This is a logical
182 shift: zeroes are inserted in the vacated bits regardless of the sign
183 of x . The result is unspecified if n < 0 or n > Sys.int_size .
184
185
186
187
188 Predicates and comparisons
189 val equal : int -> int -> bool
190
191
192 equal x y is true if and only if x = y .
193
194
195
196 val compare : int -> int -> int
197
198
199 compare x y is compare x y but more efficient.
200
201
202
203
204 Converting
205 val to_float : int -> float
206
207
208 to_float x is x as a floating point number.
209
210
211
212 val of_float : float -> int
213
214
215 of_float x truncates x to an integer. The result is unspecified if the
216 argument is nan or falls outside the range of representable integers.
217
218
219
220 val to_string : int -> string
221
222
223 to_string x is the written representation of x in decimal.
224
225
226
227
228
229OCamldoc 2021-07-22 Stdlib.Int(3)