@grain/stdlib 0.6.3 → 0.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/LICENSE +1 -1
- package/array.gr +2 -0
- package/bytes.gr +38 -7
- package/float32.gr +68 -0
- package/float32.md +164 -0
- package/float64.gr +87 -16
- package/float64.md +164 -0
- package/hash.gr +2 -0
- package/int16.gr +85 -0
- package/int16.md +168 -0
- package/int32.gr +107 -0
- package/int32.md +235 -0
- package/int64.gr +107 -0
- package/int64.md +235 -0
- package/int8.gr +1 -1
- package/int8.md +1 -1
- package/map.gr +3 -2
- package/package.json +1 -1
- package/pervasives.md +10 -3
- package/runtime/malloc.gr +269 -135
- package/runtime/malloc.md +3 -10
- package/runtime/numbers.gr +181 -100
- package/runtime/string.gr +1 -0
- package/runtime/string.md +10 -3
- package/set.gr +0 -5
- package/string.gr +291 -72
- package/string.md +108 -0
- package/wasi/file.gr +5 -0
- package/wasi/process.gr +2 -1
package/int32.gr
CHANGED
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @example from "int32" include Int32
|
|
5
5
|
*
|
|
6
|
+
* @example 1l
|
|
7
|
+
* @example -1l
|
|
8
|
+
*
|
|
6
9
|
* @since v0.2.0
|
|
7
10
|
*/
|
|
8
11
|
module Int32
|
|
@@ -48,6 +51,8 @@ provide { fromNumber, toNumber }
|
|
|
48
51
|
* @param number: The value to convert
|
|
49
52
|
* @returns The Uint32 represented as an Int32
|
|
50
53
|
*
|
|
54
|
+
* @example Int32.fromUint32(1ul) == 1l
|
|
55
|
+
*
|
|
51
56
|
* @since v0.6.0
|
|
52
57
|
*/
|
|
53
58
|
@unsafe
|
|
@@ -63,6 +68,9 @@ provide let fromUint32 = (number: Uint32) => {
|
|
|
63
68
|
* @param value: The value to increment
|
|
64
69
|
* @returns The incremented value
|
|
65
70
|
*
|
|
71
|
+
* @example Int32.incr(1l) == 2l
|
|
72
|
+
* @example Int32.incr(-2l) == -1l
|
|
73
|
+
*
|
|
66
74
|
* @since v0.2.0
|
|
67
75
|
*/
|
|
68
76
|
@unsafe
|
|
@@ -78,6 +86,9 @@ provide let incr = (value: Int32) => {
|
|
|
78
86
|
* @param value: The value to decrement
|
|
79
87
|
* @returns The decremented value
|
|
80
88
|
*
|
|
89
|
+
* @example Int32.decr(2l) == 1l
|
|
90
|
+
* @example Int32.decr(0l) == -1l
|
|
91
|
+
*
|
|
81
92
|
* @since v0.2.0
|
|
82
93
|
*/
|
|
83
94
|
@unsafe
|
|
@@ -94,6 +105,10 @@ provide let decr = (value: Int32) => {
|
|
|
94
105
|
* @param y: The second operand
|
|
95
106
|
* @returns The sum of the two operands
|
|
96
107
|
*
|
|
108
|
+
* @example
|
|
109
|
+
* use Int32.{ (+) }
|
|
110
|
+
* assert 1l + 1l == 2l
|
|
111
|
+
*
|
|
97
112
|
* @since v0.6.0
|
|
98
113
|
* @history v0.2.0: Originally named `add`
|
|
99
114
|
*/
|
|
@@ -112,6 +127,10 @@ provide let (+) = (x: Int32, y: Int32) => {
|
|
|
112
127
|
* @param y: The second operand
|
|
113
128
|
* @returns The difference of the two operands
|
|
114
129
|
*
|
|
130
|
+
* @example
|
|
131
|
+
* use Int32.{ (-) }
|
|
132
|
+
* assert 2l - 1l == 1l
|
|
133
|
+
*
|
|
115
134
|
* @since v0.6.0
|
|
116
135
|
* @history v0.2.0: Originally named `sub`
|
|
117
136
|
*/
|
|
@@ -130,6 +149,10 @@ provide let (-) = (x: Int32, y: Int32) => {
|
|
|
130
149
|
* @param y: The second operand
|
|
131
150
|
* @returns The product of the two operands
|
|
132
151
|
*
|
|
152
|
+
* @example
|
|
153
|
+
* use Int32.{ (*) }
|
|
154
|
+
* assert 2l * 2l == 4l
|
|
155
|
+
*
|
|
133
156
|
* @since v0.6.0
|
|
134
157
|
* @history v0.2.0: Originally named `mul`
|
|
135
158
|
*/
|
|
@@ -148,6 +171,10 @@ provide let (*) = (x: Int32, y: Int32) => {
|
|
|
148
171
|
* @param y: The second operand
|
|
149
172
|
* @returns The quotient of its operands
|
|
150
173
|
*
|
|
174
|
+
* @example
|
|
175
|
+
* use Int32.{ (/) }
|
|
176
|
+
* assert 8l / 2l == 4l
|
|
177
|
+
*
|
|
151
178
|
* @since v0.6.0
|
|
152
179
|
* @history v0.2.0: Originally named `div`
|
|
153
180
|
*/
|
|
@@ -166,6 +193,8 @@ provide let (/) = (x: Int32, y: Int32) => {
|
|
|
166
193
|
* @param y: The second operand
|
|
167
194
|
* @returns The remainder of its operands
|
|
168
195
|
*
|
|
196
|
+
* @example Int32.rem(8l, 3l) == 2l
|
|
197
|
+
*
|
|
169
198
|
* @since v0.2.0
|
|
170
199
|
*/
|
|
171
200
|
@unsafe
|
|
@@ -193,6 +222,10 @@ let abs = n => {
|
|
|
193
222
|
*
|
|
194
223
|
* @throws ModuloByZero: When `y` is zero
|
|
195
224
|
*
|
|
225
|
+
* @example
|
|
226
|
+
* use Int32.{ (%) }
|
|
227
|
+
* assert -5l % 3l == 1l
|
|
228
|
+
*
|
|
196
229
|
* @since v0.6.0
|
|
197
230
|
* @history v0.2.0: Originally named `mod`
|
|
198
231
|
*/
|
|
@@ -225,6 +258,9 @@ provide let (%) = (x: Int32, y: Int32) => {
|
|
|
225
258
|
* @param amount: The number of bits to rotate by
|
|
226
259
|
* @returns The rotated value
|
|
227
260
|
*
|
|
261
|
+
* @example Int32.rotl(1l, 1l) == 2l
|
|
262
|
+
* @example Int32.rotl(1l, 2l) == 4l
|
|
263
|
+
*
|
|
228
264
|
* @since v0.4.0
|
|
229
265
|
*/
|
|
230
266
|
@unsafe
|
|
@@ -242,6 +278,9 @@ provide let rotl = (value: Int32, amount: Int32) => {
|
|
|
242
278
|
* @param amount: The number of bits to rotate by
|
|
243
279
|
* @returns The rotated value
|
|
244
280
|
*
|
|
281
|
+
* @example Int32.rotr(2l, 1l) == 1l
|
|
282
|
+
* @example Int32.rotr(4l, 2l) == 1l
|
|
283
|
+
*
|
|
245
284
|
* @since v0.4.0
|
|
246
285
|
*/
|
|
247
286
|
@unsafe
|
|
@@ -259,6 +298,10 @@ provide let rotr = (value: Int32, amount: Int32) => {
|
|
|
259
298
|
* @param amount: The number of bits to shift by
|
|
260
299
|
* @returns The shifted value
|
|
261
300
|
*
|
|
301
|
+
* @example
|
|
302
|
+
* use Int32.{ (<<) }
|
|
303
|
+
* assert (5l << 1l) == 10l
|
|
304
|
+
*
|
|
262
305
|
* @since v0.6.0
|
|
263
306
|
* @history v0.2.0: Originally named `shl`
|
|
264
307
|
*/
|
|
@@ -277,6 +320,10 @@ provide let (<<) = (value: Int32, amount: Int32) => {
|
|
|
277
320
|
* @param amount: The amount to shift by
|
|
278
321
|
* @returns The shifted value
|
|
279
322
|
*
|
|
323
|
+
* @example
|
|
324
|
+
* use Int32.{ (>>) }
|
|
325
|
+
* assert (5l >> 1l) == 2l
|
|
326
|
+
*
|
|
280
327
|
* @since v0.6.0
|
|
281
328
|
* @history v0.2.0: Originally named `shr`
|
|
282
329
|
*/
|
|
@@ -295,6 +342,10 @@ provide let (>>) = (value: Int32, amount: Int32) => {
|
|
|
295
342
|
* @param y: The second value
|
|
296
343
|
* @returns `true` if the first value is equal to the second value or `false` otherwise
|
|
297
344
|
*
|
|
345
|
+
* @example
|
|
346
|
+
* use Int32.{ (==) }
|
|
347
|
+
* assert 1l == 1l
|
|
348
|
+
*
|
|
298
349
|
* @since v0.6.0
|
|
299
350
|
* @history v0.4.0: Originally named `eq`
|
|
300
351
|
*/
|
|
@@ -312,6 +363,10 @@ provide let (==) = (x: Int32, y: Int32) => {
|
|
|
312
363
|
* @param y: The second value
|
|
313
364
|
* @returns `true` if the first value is not equal to the second value or `false` otherwise
|
|
314
365
|
*
|
|
366
|
+
* @example
|
|
367
|
+
* use Int32.{ (!=) }
|
|
368
|
+
* assert 1l != 2l
|
|
369
|
+
*
|
|
315
370
|
* @since v0.6.0
|
|
316
371
|
* @history v0.4.0: Originally named `ne`
|
|
317
372
|
*/
|
|
@@ -328,6 +383,9 @@ provide let (!=) = (x: Int32, y: Int32) => {
|
|
|
328
383
|
* @param value: The value to inspect
|
|
329
384
|
* @returns `true` if the first value is equal to zero or `false` otherwise
|
|
330
385
|
*
|
|
386
|
+
* @example Int32.eqz(0l) == true
|
|
387
|
+
* @example Int32.eqz(1l) == false
|
|
388
|
+
*
|
|
331
389
|
* @since v0.4.0
|
|
332
390
|
*/
|
|
333
391
|
@unsafe
|
|
@@ -343,6 +401,10 @@ provide let eqz = (value: Int32) => {
|
|
|
343
401
|
* @param y: The second value
|
|
344
402
|
* @returns `true` if the first value is less than the second value or `false` otherwise
|
|
345
403
|
*
|
|
404
|
+
* @example
|
|
405
|
+
* use Int32.{ (<) }
|
|
406
|
+
* assert 1l < 2l
|
|
407
|
+
*
|
|
346
408
|
* @since v0.6.0
|
|
347
409
|
* @history v0.2.0: Originally named `lt`
|
|
348
410
|
*/
|
|
@@ -360,6 +422,10 @@ provide let (<) = (x: Int32, y: Int32) => {
|
|
|
360
422
|
* @param y: The second value
|
|
361
423
|
* @returns `true` if the first value is greater than the second value or `false` otherwise
|
|
362
424
|
*
|
|
425
|
+
* @example
|
|
426
|
+
* use Int32.{ (>) }
|
|
427
|
+
* assert 2l > 1l
|
|
428
|
+
*
|
|
363
429
|
* @since v0.6.0
|
|
364
430
|
* @history v0.2.0: Originally named `gt`
|
|
365
431
|
*/
|
|
@@ -377,6 +443,13 @@ provide let (>) = (x: Int32, y: Int32) => {
|
|
|
377
443
|
* @param y: The second value
|
|
378
444
|
* @returns `true` if the first value is less than or equal to the second value or `false` otherwise
|
|
379
445
|
*
|
|
446
|
+
* @example
|
|
447
|
+
* use Int32.{ (<=) }
|
|
448
|
+
* assert 1l <= 2l
|
|
449
|
+
* @example
|
|
450
|
+
* use Int32.{ (<=) }
|
|
451
|
+
* assert 1l <= 1l
|
|
452
|
+
*
|
|
380
453
|
* @since v0.6.0
|
|
381
454
|
* @history v0.2.0: Originally named `lte`
|
|
382
455
|
*/
|
|
@@ -394,6 +467,13 @@ provide let (<=) = (x: Int32, y: Int32) => {
|
|
|
394
467
|
* @param y: The second value
|
|
395
468
|
* @returns `true` if the first value is greater than or equal to the second value or `false` otherwise
|
|
396
469
|
*
|
|
470
|
+
* @example
|
|
471
|
+
* use Int32.{ (>=) }
|
|
472
|
+
* assert 2l >= 1l
|
|
473
|
+
* @example
|
|
474
|
+
* use Int32.{ (>=) }
|
|
475
|
+
* assert 1l >= 1l
|
|
476
|
+
*
|
|
397
477
|
* @since v0.6.0
|
|
398
478
|
* @history v0.2.0: Originally named `gte`
|
|
399
479
|
*/
|
|
@@ -410,6 +490,8 @@ provide let (>=) = (x: Int32, y: Int32) => {
|
|
|
410
490
|
* @param value: The given value
|
|
411
491
|
* @returns Containing the inverted bits of the given value
|
|
412
492
|
*
|
|
493
|
+
* @example Int32.lnot(-5l) == 4l
|
|
494
|
+
*
|
|
413
495
|
* @since v0.2.0
|
|
414
496
|
*/
|
|
415
497
|
@unsafe
|
|
@@ -426,6 +508,10 @@ provide let lnot = (value: Int32) => {
|
|
|
426
508
|
* @param y: The second operand
|
|
427
509
|
* @returns Containing a `1` in each bit position for which the corresponding bits of both operands are `1`
|
|
428
510
|
*
|
|
511
|
+
* @example
|
|
512
|
+
* use Int32.{ (&) }
|
|
513
|
+
* assert (3l & 4l) == 0l
|
|
514
|
+
*
|
|
429
515
|
* @since v0.6.0
|
|
430
516
|
* @history v0.2.0: Originally named `land`
|
|
431
517
|
*/
|
|
@@ -444,6 +530,10 @@ provide let (&) = (x: Int32, y: Int32) => {
|
|
|
444
530
|
* @param y: The second operand
|
|
445
531
|
* @returns Containing a `1` in each bit position for which the corresponding bits of either or both operands are `1`
|
|
446
532
|
*
|
|
533
|
+
* @example
|
|
534
|
+
* use Int32.{ (|) }
|
|
535
|
+
* assert (3l | 4l) == 7l
|
|
536
|
+
*
|
|
447
537
|
* @since v0.6.0
|
|
448
538
|
* @history v0.2.0: Originally named `lor`
|
|
449
539
|
*/
|
|
@@ -462,6 +552,10 @@ provide let (|) = (x: Int32, y: Int32) => {
|
|
|
462
552
|
* @param y: The second operand
|
|
463
553
|
* @returns Containing a `1` in each bit position for which the corresponding bits of either but not both operands are `1`
|
|
464
554
|
*
|
|
555
|
+
* @example
|
|
556
|
+
* use Int32.{ (^) }
|
|
557
|
+
* assert (3l ^ 5l) == 6l
|
|
558
|
+
*
|
|
465
559
|
* @since v0.6.0
|
|
466
560
|
* @history v0.2.0: Originally named `lxor`
|
|
467
561
|
*/
|
|
@@ -479,6 +573,9 @@ provide let (^) = (x: Int32, y: Int32) => {
|
|
|
479
573
|
* @param value: The value to inspect
|
|
480
574
|
* @returns The amount of leading zeros
|
|
481
575
|
*
|
|
576
|
+
* @example Int32.clz(1l) == 31l
|
|
577
|
+
* @example Int32.clz(4l) == 29l
|
|
578
|
+
*
|
|
482
579
|
* @since v0.4.0
|
|
483
580
|
*/
|
|
484
581
|
@unsafe
|
|
@@ -494,6 +591,9 @@ provide let clz = (value: Int32) => {
|
|
|
494
591
|
* @param value: The value to inspect
|
|
495
592
|
* @returns The amount of trailing zeros
|
|
496
593
|
*
|
|
594
|
+
* @example Int32.ctz(1l) == 0l
|
|
595
|
+
* @example Int32.ctz(4l) == 2l
|
|
596
|
+
*
|
|
497
597
|
* @since v0.4.0
|
|
498
598
|
*/
|
|
499
599
|
@unsafe
|
|
@@ -509,6 +609,9 @@ provide let ctz = (value: Int32) => {
|
|
|
509
609
|
* @param value: The value to inspect
|
|
510
610
|
* @returns The amount of 1-bits in its operand
|
|
511
611
|
*
|
|
612
|
+
* @example Int32.popcnt(1l) == 1l
|
|
613
|
+
* @example Int32.popcnt(3l) == 2l
|
|
614
|
+
*
|
|
512
615
|
* @since v0.4.0
|
|
513
616
|
*/
|
|
514
617
|
@unsafe
|
|
@@ -538,6 +641,10 @@ let rec expBySquaring = (y, x, n) => {
|
|
|
538
641
|
* @param power: The exponent number
|
|
539
642
|
* @returns The base raised to the given power
|
|
540
643
|
*
|
|
644
|
+
* @example
|
|
645
|
+
* from Int32 use { (**) }
|
|
646
|
+
* assert 2l ** 3l == 8l
|
|
647
|
+
*
|
|
541
648
|
* @since v0.6.0
|
|
542
649
|
*/
|
|
543
650
|
provide let (**) = (base, power) => {
|
package/int32.md
CHANGED
|
@@ -13,6 +13,14 @@ No other changes yet.
|
|
|
13
13
|
from "int32" include Int32
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
+
```grain
|
|
17
|
+
1l
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
```grain
|
|
21
|
+
-1l
|
|
22
|
+
```
|
|
23
|
+
|
|
16
24
|
## Values
|
|
17
25
|
|
|
18
26
|
Functions and constants included in the Int32 module.
|
|
@@ -92,6 +100,12 @@ Returns:
|
|
|
92
100
|
|----|-----------|
|
|
93
101
|
|`Int32`|The Uint32 represented as an Int32|
|
|
94
102
|
|
|
103
|
+
Examples:
|
|
104
|
+
|
|
105
|
+
```grain
|
|
106
|
+
Int32.fromUint32(1ul) == 1l
|
|
107
|
+
```
|
|
108
|
+
|
|
95
109
|
### Int32.**incr**
|
|
96
110
|
|
|
97
111
|
<details disabled>
|
|
@@ -117,6 +131,16 @@ Returns:
|
|
|
117
131
|
|----|-----------|
|
|
118
132
|
|`Int32`|The incremented value|
|
|
119
133
|
|
|
134
|
+
Examples:
|
|
135
|
+
|
|
136
|
+
```grain
|
|
137
|
+
Int32.incr(1l) == 2l
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
```grain
|
|
141
|
+
Int32.incr(-2l) == -1l
|
|
142
|
+
```
|
|
143
|
+
|
|
120
144
|
### Int32.**decr**
|
|
121
145
|
|
|
122
146
|
<details disabled>
|
|
@@ -142,6 +166,16 @@ Returns:
|
|
|
142
166
|
|----|-----------|
|
|
143
167
|
|`Int32`|The decremented value|
|
|
144
168
|
|
|
169
|
+
Examples:
|
|
170
|
+
|
|
171
|
+
```grain
|
|
172
|
+
Int32.decr(2l) == 1l
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
```grain
|
|
176
|
+
Int32.decr(0l) == -1l
|
|
177
|
+
```
|
|
178
|
+
|
|
145
179
|
### Int32.**(+)**
|
|
146
180
|
|
|
147
181
|
<details>
|
|
@@ -175,6 +209,13 @@ Returns:
|
|
|
175
209
|
|----|-----------|
|
|
176
210
|
|`Int32`|The sum of the two operands|
|
|
177
211
|
|
|
212
|
+
Examples:
|
|
213
|
+
|
|
214
|
+
```grain
|
|
215
|
+
use Int32.{ (+) }
|
|
216
|
+
assert 1l + 1l == 2l
|
|
217
|
+
```
|
|
218
|
+
|
|
178
219
|
### Int32.**(-)**
|
|
179
220
|
|
|
180
221
|
<details>
|
|
@@ -208,6 +249,13 @@ Returns:
|
|
|
208
249
|
|----|-----------|
|
|
209
250
|
|`Int32`|The difference of the two operands|
|
|
210
251
|
|
|
252
|
+
Examples:
|
|
253
|
+
|
|
254
|
+
```grain
|
|
255
|
+
use Int32.{ (-) }
|
|
256
|
+
assert 2l - 1l == 1l
|
|
257
|
+
```
|
|
258
|
+
|
|
211
259
|
### Int32.**(*)**
|
|
212
260
|
|
|
213
261
|
<details>
|
|
@@ -241,6 +289,13 @@ Returns:
|
|
|
241
289
|
|----|-----------|
|
|
242
290
|
|`Int32`|The product of the two operands|
|
|
243
291
|
|
|
292
|
+
Examples:
|
|
293
|
+
|
|
294
|
+
```grain
|
|
295
|
+
use Int32.{ (*) }
|
|
296
|
+
assert 2l * 2l == 4l
|
|
297
|
+
```
|
|
298
|
+
|
|
244
299
|
### Int32.**(/)**
|
|
245
300
|
|
|
246
301
|
<details>
|
|
@@ -274,6 +329,13 @@ Returns:
|
|
|
274
329
|
|----|-----------|
|
|
275
330
|
|`Int32`|The quotient of its operands|
|
|
276
331
|
|
|
332
|
+
Examples:
|
|
333
|
+
|
|
334
|
+
```grain
|
|
335
|
+
use Int32.{ (/) }
|
|
336
|
+
assert 8l / 2l == 4l
|
|
337
|
+
```
|
|
338
|
+
|
|
277
339
|
### Int32.**rem**
|
|
278
340
|
|
|
279
341
|
<details disabled>
|
|
@@ -300,6 +362,12 @@ Returns:
|
|
|
300
362
|
|----|-----------|
|
|
301
363
|
|`Int32`|The remainder of its operands|
|
|
302
364
|
|
|
365
|
+
Examples:
|
|
366
|
+
|
|
367
|
+
```grain
|
|
368
|
+
Int32.rem(8l, 3l) == 2l
|
|
369
|
+
```
|
|
370
|
+
|
|
303
371
|
### Int32.**(%)**
|
|
304
372
|
|
|
305
373
|
<details>
|
|
@@ -340,6 +408,13 @@ Throws:
|
|
|
340
408
|
|
|
341
409
|
* When `y` is zero
|
|
342
410
|
|
|
411
|
+
Examples:
|
|
412
|
+
|
|
413
|
+
```grain
|
|
414
|
+
use Int32.{ (%) }
|
|
415
|
+
assert -5l % 3l == 1l
|
|
416
|
+
```
|
|
417
|
+
|
|
343
418
|
### Int32.**rotl**
|
|
344
419
|
|
|
345
420
|
<details disabled>
|
|
@@ -366,6 +441,16 @@ Returns:
|
|
|
366
441
|
|----|-----------|
|
|
367
442
|
|`Int32`|The rotated value|
|
|
368
443
|
|
|
444
|
+
Examples:
|
|
445
|
+
|
|
446
|
+
```grain
|
|
447
|
+
Int32.rotl(1l, 1l) == 2l
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
```grain
|
|
451
|
+
Int32.rotl(1l, 2l) == 4l
|
|
452
|
+
```
|
|
453
|
+
|
|
369
454
|
### Int32.**rotr**
|
|
370
455
|
|
|
371
456
|
<details disabled>
|
|
@@ -392,6 +477,16 @@ Returns:
|
|
|
392
477
|
|----|-----------|
|
|
393
478
|
|`Int32`|The rotated value|
|
|
394
479
|
|
|
480
|
+
Examples:
|
|
481
|
+
|
|
482
|
+
```grain
|
|
483
|
+
Int32.rotr(2l, 1l) == 1l
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
```grain
|
|
487
|
+
Int32.rotr(4l, 2l) == 1l
|
|
488
|
+
```
|
|
489
|
+
|
|
395
490
|
### Int32.**(<<)**
|
|
396
491
|
|
|
397
492
|
<details>
|
|
@@ -425,6 +520,13 @@ Returns:
|
|
|
425
520
|
|----|-----------|
|
|
426
521
|
|`Int32`|The shifted value|
|
|
427
522
|
|
|
523
|
+
Examples:
|
|
524
|
+
|
|
525
|
+
```grain
|
|
526
|
+
use Int32.{ (<<) }
|
|
527
|
+
assert (5l << 1l) == 10l
|
|
528
|
+
```
|
|
529
|
+
|
|
428
530
|
### Int32.**(>>)**
|
|
429
531
|
|
|
430
532
|
<details>
|
|
@@ -458,6 +560,13 @@ Returns:
|
|
|
458
560
|
|----|-----------|
|
|
459
561
|
|`Int32`|The shifted value|
|
|
460
562
|
|
|
563
|
+
Examples:
|
|
564
|
+
|
|
565
|
+
```grain
|
|
566
|
+
use Int32.{ (>>) }
|
|
567
|
+
assert (5l >> 1l) == 2l
|
|
568
|
+
```
|
|
569
|
+
|
|
461
570
|
### Int32.**(==)**
|
|
462
571
|
|
|
463
572
|
<details>
|
|
@@ -491,6 +600,13 @@ Returns:
|
|
|
491
600
|
|----|-----------|
|
|
492
601
|
|`Bool`|`true` if the first value is equal to the second value or `false` otherwise|
|
|
493
602
|
|
|
603
|
+
Examples:
|
|
604
|
+
|
|
605
|
+
```grain
|
|
606
|
+
use Int32.{ (==) }
|
|
607
|
+
assert 1l == 1l
|
|
608
|
+
```
|
|
609
|
+
|
|
494
610
|
### Int32.**(!=)**
|
|
495
611
|
|
|
496
612
|
<details>
|
|
@@ -524,6 +640,13 @@ Returns:
|
|
|
524
640
|
|----|-----------|
|
|
525
641
|
|`Bool`|`true` if the first value is not equal to the second value or `false` otherwise|
|
|
526
642
|
|
|
643
|
+
Examples:
|
|
644
|
+
|
|
645
|
+
```grain
|
|
646
|
+
use Int32.{ (!=) }
|
|
647
|
+
assert 1l != 2l
|
|
648
|
+
```
|
|
649
|
+
|
|
527
650
|
### Int32.**eqz**
|
|
528
651
|
|
|
529
652
|
<details disabled>
|
|
@@ -549,6 +672,16 @@ Returns:
|
|
|
549
672
|
|----|-----------|
|
|
550
673
|
|`Bool`|`true` if the first value is equal to zero or `false` otherwise|
|
|
551
674
|
|
|
675
|
+
Examples:
|
|
676
|
+
|
|
677
|
+
```grain
|
|
678
|
+
Int32.eqz(0l) == true
|
|
679
|
+
```
|
|
680
|
+
|
|
681
|
+
```grain
|
|
682
|
+
Int32.eqz(1l) == false
|
|
683
|
+
```
|
|
684
|
+
|
|
552
685
|
### Int32.**(<)**
|
|
553
686
|
|
|
554
687
|
<details>
|
|
@@ -582,6 +715,13 @@ Returns:
|
|
|
582
715
|
|----|-----------|
|
|
583
716
|
|`Bool`|`true` if the first value is less than the second value or `false` otherwise|
|
|
584
717
|
|
|
718
|
+
Examples:
|
|
719
|
+
|
|
720
|
+
```grain
|
|
721
|
+
use Int32.{ (<) }
|
|
722
|
+
assert 1l < 2l
|
|
723
|
+
```
|
|
724
|
+
|
|
585
725
|
### Int32.**(>)**
|
|
586
726
|
|
|
587
727
|
<details>
|
|
@@ -615,6 +755,13 @@ Returns:
|
|
|
615
755
|
|----|-----------|
|
|
616
756
|
|`Bool`|`true` if the first value is greater than the second value or `false` otherwise|
|
|
617
757
|
|
|
758
|
+
Examples:
|
|
759
|
+
|
|
760
|
+
```grain
|
|
761
|
+
use Int32.{ (>) }
|
|
762
|
+
assert 2l > 1l
|
|
763
|
+
```
|
|
764
|
+
|
|
618
765
|
### Int32.**(<=)**
|
|
619
766
|
|
|
620
767
|
<details>
|
|
@@ -648,6 +795,18 @@ Returns:
|
|
|
648
795
|
|----|-----------|
|
|
649
796
|
|`Bool`|`true` if the first value is less than or equal to the second value or `false` otherwise|
|
|
650
797
|
|
|
798
|
+
Examples:
|
|
799
|
+
|
|
800
|
+
```grain
|
|
801
|
+
use Int32.{ (<=) }
|
|
802
|
+
assert 1l <= 2l
|
|
803
|
+
```
|
|
804
|
+
|
|
805
|
+
```grain
|
|
806
|
+
use Int32.{ (<=) }
|
|
807
|
+
assert 1l <= 1l
|
|
808
|
+
```
|
|
809
|
+
|
|
651
810
|
### Int32.**(>=)**
|
|
652
811
|
|
|
653
812
|
<details>
|
|
@@ -681,6 +840,18 @@ Returns:
|
|
|
681
840
|
|----|-----------|
|
|
682
841
|
|`Bool`|`true` if the first value is greater than or equal to the second value or `false` otherwise|
|
|
683
842
|
|
|
843
|
+
Examples:
|
|
844
|
+
|
|
845
|
+
```grain
|
|
846
|
+
use Int32.{ (>=) }
|
|
847
|
+
assert 2l >= 1l
|
|
848
|
+
```
|
|
849
|
+
|
|
850
|
+
```grain
|
|
851
|
+
use Int32.{ (>=) }
|
|
852
|
+
assert 1l >= 1l
|
|
853
|
+
```
|
|
854
|
+
|
|
684
855
|
### Int32.**lnot**
|
|
685
856
|
|
|
686
857
|
<details disabled>
|
|
@@ -706,6 +877,12 @@ Returns:
|
|
|
706
877
|
|----|-----------|
|
|
707
878
|
|`Int32`|Containing the inverted bits of the given value|
|
|
708
879
|
|
|
880
|
+
Examples:
|
|
881
|
+
|
|
882
|
+
```grain
|
|
883
|
+
Int32.lnot(-5l) == 4l
|
|
884
|
+
```
|
|
885
|
+
|
|
709
886
|
### Int32.**(&)**
|
|
710
887
|
|
|
711
888
|
<details>
|
|
@@ -739,6 +916,13 @@ Returns:
|
|
|
739
916
|
|----|-----------|
|
|
740
917
|
|`Int32`|Containing a `1` in each bit position for which the corresponding bits of both operands are `1`|
|
|
741
918
|
|
|
919
|
+
Examples:
|
|
920
|
+
|
|
921
|
+
```grain
|
|
922
|
+
use Int32.{ (&) }
|
|
923
|
+
assert (3l & 4l) == 0l
|
|
924
|
+
```
|
|
925
|
+
|
|
742
926
|
### Int32.**(|)**
|
|
743
927
|
|
|
744
928
|
<details>
|
|
@@ -772,6 +956,13 @@ Returns:
|
|
|
772
956
|
|----|-----------|
|
|
773
957
|
|`Int32`|Containing a `1` in each bit position for which the corresponding bits of either or both operands are `1`|
|
|
774
958
|
|
|
959
|
+
Examples:
|
|
960
|
+
|
|
961
|
+
```grain
|
|
962
|
+
use Int32.{ (|) }
|
|
963
|
+
assert (3l | 4l) == 7l
|
|
964
|
+
```
|
|
965
|
+
|
|
775
966
|
### Int32.**(^)**
|
|
776
967
|
|
|
777
968
|
<details>
|
|
@@ -805,6 +996,13 @@ Returns:
|
|
|
805
996
|
|----|-----------|
|
|
806
997
|
|`Int32`|Containing a `1` in each bit position for which the corresponding bits of either but not both operands are `1`|
|
|
807
998
|
|
|
999
|
+
Examples:
|
|
1000
|
+
|
|
1001
|
+
```grain
|
|
1002
|
+
use Int32.{ (^) }
|
|
1003
|
+
assert (3l ^ 5l) == 6l
|
|
1004
|
+
```
|
|
1005
|
+
|
|
808
1006
|
### Int32.**clz**
|
|
809
1007
|
|
|
810
1008
|
<details disabled>
|
|
@@ -830,6 +1028,16 @@ Returns:
|
|
|
830
1028
|
|----|-----------|
|
|
831
1029
|
|`Int32`|The amount of leading zeros|
|
|
832
1030
|
|
|
1031
|
+
Examples:
|
|
1032
|
+
|
|
1033
|
+
```grain
|
|
1034
|
+
Int32.clz(1l) == 31l
|
|
1035
|
+
```
|
|
1036
|
+
|
|
1037
|
+
```grain
|
|
1038
|
+
Int32.clz(4l) == 29l
|
|
1039
|
+
```
|
|
1040
|
+
|
|
833
1041
|
### Int32.**ctz**
|
|
834
1042
|
|
|
835
1043
|
<details disabled>
|
|
@@ -855,6 +1063,16 @@ Returns:
|
|
|
855
1063
|
|----|-----------|
|
|
856
1064
|
|`Int32`|The amount of trailing zeros|
|
|
857
1065
|
|
|
1066
|
+
Examples:
|
|
1067
|
+
|
|
1068
|
+
```grain
|
|
1069
|
+
Int32.ctz(1l) == 0l
|
|
1070
|
+
```
|
|
1071
|
+
|
|
1072
|
+
```grain
|
|
1073
|
+
Int32.ctz(4l) == 2l
|
|
1074
|
+
```
|
|
1075
|
+
|
|
858
1076
|
### Int32.**popcnt**
|
|
859
1077
|
|
|
860
1078
|
<details disabled>
|
|
@@ -880,6 +1098,16 @@ Returns:
|
|
|
880
1098
|
|----|-----------|
|
|
881
1099
|
|`Int32`|The amount of 1-bits in its operand|
|
|
882
1100
|
|
|
1101
|
+
Examples:
|
|
1102
|
+
|
|
1103
|
+
```grain
|
|
1104
|
+
Int32.popcnt(1l) == 1l
|
|
1105
|
+
```
|
|
1106
|
+
|
|
1107
|
+
```grain
|
|
1108
|
+
Int32.popcnt(3l) == 2l
|
|
1109
|
+
```
|
|
1110
|
+
|
|
883
1111
|
### Int32.**(\*\*)**
|
|
884
1112
|
|
|
885
1113
|
<details disabled>
|
|
@@ -906,3 +1134,10 @@ Returns:
|
|
|
906
1134
|
|----|-----------|
|
|
907
1135
|
|`Int32`|The base raised to the given power|
|
|
908
1136
|
|
|
1137
|
+
Examples:
|
|
1138
|
+
|
|
1139
|
+
```grain
|
|
1140
|
+
from Int32 use { (**) }
|
|
1141
|
+
assert 2l ** 3l == 8l
|
|
1142
|
+
```
|
|
1143
|
+
|