File tree Expand file tree Collapse file tree 3 files changed +92
-0
lines changed Expand file tree Collapse file tree 3 files changed +92
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,10 @@ function fromString(x, radix) {
11
11
}
12
12
}
13
13
14
+ function lnot ( x ) {
15
+ return x ^ - 1 ;
16
+ }
17
+
14
18
function abs ( x ) {
15
19
if ( x >= 0 ) {
16
20
return x ;
@@ -72,6 +76,7 @@ var Constants = {
72
76
export {
73
77
Constants ,
74
78
fromString ,
79
+ lnot ,
75
80
range ,
76
81
rangeWithOptions ,
77
82
clamp ,
Original file line number Diff line number Diff line change @@ -45,6 +45,16 @@ let fromString = (x, ~radix=?) => {
45
45
46
46
external mod : (int , int ) => int = "%modint"
47
47
48
+ external land : (int , int ) => int = "%andint"
49
+ external lor : (int , int ) => int = "%orint"
50
+ external lxor : (int , int ) => int = "%xorint"
51
+
52
+ external lsl : (int , int ) => int = "%lslint"
53
+ external lsr : (int , int ) => int = "%lsrint"
54
+ external asr : (int , int ) => int = "%asrint"
55
+
56
+ let lnot = x => lxor (x , - 1 )
57
+
48
58
type rangeOptions = {step ?: int , inclusive ?: bool }
49
59
50
60
let abs = x =>
Original file line number Diff line number Diff line change @@ -292,6 +292,83 @@ Int.fromString("6", ~radix=2) == None
292
292
*/
293
293
let fromString: (string, ~radix: int=?) => option<int>
294
294
295
+ /**
296
+ `land(n1, n2)` calculates the bitwise logical AND of two integers.
297
+
298
+ ## Examples
299
+
300
+ ```rescript
301
+ Int.land(7, 4) == 4
302
+ ```
303
+ */
304
+ external land: (int, int) => int = "%andint"
305
+
306
+ /**
307
+ `lor(n1, n2)` calculates the bitwise logical OR of two integers.
308
+
309
+ ## Examples
310
+
311
+ ```rescript
312
+ Int.lor(7, 4) == 7
313
+ ```
314
+ */
315
+ external lor: (int, int) => int = "%orint"
316
+
317
+ /**
318
+ `lxor(n1, n2)` calculates the bitwise logical XOR of two integers.
319
+
320
+ ## Examples
321
+
322
+ ```rescript
323
+ Int.lxor(7, 4) == 3
324
+ ```
325
+ */
326
+ external lxor: (int, int) => int = "%xorint"
327
+
328
+ /**
329
+ `lnot(n)` calculates the bitwise logical NOT of an integer.
330
+
331
+ ## Examples
332
+
333
+ ```rescript
334
+ Int.lnot(2) == -3
335
+ ```
336
+ */
337
+ let lnot: int => int
338
+
339
+ /**
340
+ `lsl(n, length)` calculates the bitwise logical left shift of an integer `n` by `length`.
341
+
342
+ ## Examples
343
+
344
+ ```rescript
345
+ Int.lsl(4, 1) == 8
346
+ ```
347
+ */
348
+ external lsl: (int, int) => int = "%lslint"
349
+
350
+ /**
351
+ `lsr(n, length)` calculates the bitwise logical right shift of an integer `n` by `length`.
352
+
353
+ ## Examples
354
+
355
+ ```rescript
356
+ Int.lsr(8, 1) == 4
357
+ ```
358
+ */
359
+ external lsr: (int, int) => int = "%lsrint"
360
+
361
+ /**
362
+ `asr(n, length)` calculates the bitwise arithmetic right shift of an integer `n` by `length`.
363
+
364
+ ## Examples
365
+
366
+ ```rescript
367
+ Int.asr(4, 1) == 2
368
+ ```
369
+ */
370
+ external asr: (int, int) => int = "%asrint"
371
+
295
372
/**
296
373
`mod(n1, n2)` calculates the modulo (remainder after division) of two integers.
297
374
You can’t perform that action at this time.
0 commit comments