@grain/stdlib 0.6.4 → 0.6.6
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/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/int32.gr +107 -0
- package/int32.md +235 -0
- package/int64.gr +107 -0
- package/int64.md +235 -0
- package/list.gr +59 -18
- package/map.gr +3 -2
- package/package.json +1 -1
- package/pervasives.md +10 -3
- package/runtime/numbers.gr +181 -100
- package/runtime/string.gr +1 -0
- package/runtime/string.md +10 -3
- package/string.gr +291 -72
- package/string.md +108 -0
- package/uint16.gr +81 -0
- package/uint16.md +161 -0
- package/uint8.gr +81 -0
- package/uint8.md +161 -0
- package/wasi/file.gr +5 -0
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
|
+
|
package/int64.gr
CHANGED
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @example from "int64" include Int64
|
|
5
5
|
*
|
|
6
|
+
* @example 1L
|
|
7
|
+
* @example -1L
|
|
8
|
+
*
|
|
6
9
|
* @since v0.2.0
|
|
7
10
|
*/
|
|
8
11
|
module Int64
|
|
@@ -29,6 +32,8 @@ provide { fromNumber, toNumber }
|
|
|
29
32
|
* @param number: The value to convert
|
|
30
33
|
* @returns The Uint64 represented as an Int64
|
|
31
34
|
*
|
|
35
|
+
* @example Int64.fromUint64(1uL) == 1L
|
|
36
|
+
*
|
|
32
37
|
* @since v0.6.0
|
|
33
38
|
*/
|
|
34
39
|
@unsafe
|
|
@@ -44,6 +49,9 @@ provide let fromUint64 = (number: Uint64) => {
|
|
|
44
49
|
* @param value: The value to increment
|
|
45
50
|
* @returns The incremented value
|
|
46
51
|
*
|
|
52
|
+
* @example Int64.incr(1L) == 2L
|
|
53
|
+
* @example Int64.incr(-2L) == -1L
|
|
54
|
+
*
|
|
47
55
|
* @since v0.2.0
|
|
48
56
|
*/
|
|
49
57
|
@unsafe
|
|
@@ -60,6 +68,9 @@ provide let incr = (value: Int64) => {
|
|
|
60
68
|
* @param value: The value to decrement
|
|
61
69
|
* @returns The decremented value
|
|
62
70
|
*
|
|
71
|
+
* @example Int64.decr(2L) == 1L
|
|
72
|
+
* @example Int64.decr(0L) == -1L
|
|
73
|
+
*
|
|
63
74
|
* @since v0.2.0
|
|
64
75
|
*/
|
|
65
76
|
@unsafe
|
|
@@ -77,6 +88,10 @@ provide let decr = (value: Int64) => {
|
|
|
77
88
|
* @param y: The second operand
|
|
78
89
|
* @returns The sum of the two operands
|
|
79
90
|
*
|
|
91
|
+
* @example
|
|
92
|
+
* use Int64.{ (+) }
|
|
93
|
+
* assert 1L + 1L == 2L
|
|
94
|
+
*
|
|
80
95
|
* @since v0.6.0
|
|
81
96
|
* @history v0.2.0: Originally named `add`
|
|
82
97
|
*/
|
|
@@ -96,6 +111,10 @@ provide let (+) = (x: Int64, y: Int64) => {
|
|
|
96
111
|
* @param y: The second operand
|
|
97
112
|
* @returns The difference of the two operands
|
|
98
113
|
*
|
|
114
|
+
* @example
|
|
115
|
+
* use Int64.{ (-) }
|
|
116
|
+
* assert 2L - 1L == 1L
|
|
117
|
+
*
|
|
99
118
|
* @since v0.6.0
|
|
100
119
|
* @history v0.2.0: Originally named `sub`
|
|
101
120
|
*/
|
|
@@ -115,6 +134,10 @@ provide let (-) = (x: Int64, y: Int64) => {
|
|
|
115
134
|
* @param y: The second operand
|
|
116
135
|
* @returns The product of the two operands
|
|
117
136
|
*
|
|
137
|
+
* @example
|
|
138
|
+
* use Int64.{ (*) }
|
|
139
|
+
* assert 2L * 2L == 4L
|
|
140
|
+
*
|
|
118
141
|
* @since v0.6.0
|
|
119
142
|
* @history v0.2.0: Originally named `*`
|
|
120
143
|
*/
|
|
@@ -134,6 +157,10 @@ provide let (*) = (x: Int64, y: Int64) => {
|
|
|
134
157
|
* @param y: The second operand
|
|
135
158
|
* @returns The quotient of its operands
|
|
136
159
|
*
|
|
160
|
+
* @example
|
|
161
|
+
* use Int64.{ (/) }
|
|
162
|
+
* assert 8L / 2L == 4L
|
|
163
|
+
*
|
|
137
164
|
* @since v0.6.0
|
|
138
165
|
* @history v0.2.0: Originally named `div`
|
|
139
166
|
*/
|
|
@@ -153,6 +180,8 @@ provide let (/) = (x: Int64, y: Int64) => {
|
|
|
153
180
|
* @param y: The second operand
|
|
154
181
|
* @returns The remainder of its operands
|
|
155
182
|
*
|
|
183
|
+
* @example Int64.rem(8L, 3L) == 2L
|
|
184
|
+
*
|
|
156
185
|
* @since v0.2.0
|
|
157
186
|
*/
|
|
158
187
|
@unsafe
|
|
@@ -180,6 +209,10 @@ let abs = n => {
|
|
|
180
209
|
*
|
|
181
210
|
* @throws ModuloByZero: When `y` is zero
|
|
182
211
|
*
|
|
212
|
+
* @example
|
|
213
|
+
* use Int64.{ (%) }
|
|
214
|
+
* assert -5L % 3L == 1L
|
|
215
|
+
*
|
|
183
216
|
* @since v0.6.0
|
|
184
217
|
* @history v0.2.0: Originally named `mod`
|
|
185
218
|
*/
|
|
@@ -212,6 +245,9 @@ provide let (%) = (x: Int64, y: Int64) => {
|
|
|
212
245
|
* @param amount: The number of bits to rotate by
|
|
213
246
|
* @returns The rotated value
|
|
214
247
|
*
|
|
248
|
+
* @example Int64.rotl(1L, 1L) == 2L
|
|
249
|
+
* @example Int64.rotl(1L, 2L) == 4L
|
|
250
|
+
*
|
|
215
251
|
* @since v0.4.0
|
|
216
252
|
*/
|
|
217
253
|
@unsafe
|
|
@@ -229,6 +265,9 @@ provide let rotl = (value: Int64, amount: Int64) => {
|
|
|
229
265
|
* @param amount: The number of bits to rotate by
|
|
230
266
|
* @returns The rotated value
|
|
231
267
|
*
|
|
268
|
+
* @example Int64.rotr(2L, 1L) == 1L
|
|
269
|
+
* @example Int64.rotr(4L, 2L) == 1L
|
|
270
|
+
*
|
|
232
271
|
* @since v0.4.0
|
|
233
272
|
*/
|
|
234
273
|
@unsafe
|
|
@@ -246,6 +285,10 @@ provide let rotr = (value: Int64, amount: Int64) => {
|
|
|
246
285
|
* @param amount: The number of bits to shift by
|
|
247
286
|
* @returns The shifted value
|
|
248
287
|
*
|
|
288
|
+
* @example
|
|
289
|
+
* use Int64.{ (<<) }
|
|
290
|
+
* assert (5L << 1L) == 10L
|
|
291
|
+
*
|
|
249
292
|
* @since v0.6.0
|
|
250
293
|
* @history v0.2.0: Originally named `shl`
|
|
251
294
|
*/
|
|
@@ -264,6 +307,10 @@ provide let (<<) = (value: Int64, amount: Int64) => {
|
|
|
264
307
|
* @param amount: The amount to shift by
|
|
265
308
|
* @returns The shifted value
|
|
266
309
|
*
|
|
310
|
+
* @example
|
|
311
|
+
* use Int64.{ (>>) }
|
|
312
|
+
* assert (5L >> 1L) == 2L
|
|
313
|
+
*
|
|
267
314
|
* @since v0.6.0
|
|
268
315
|
* @history v0.2.0: Originally named `shr`
|
|
269
316
|
*/
|
|
@@ -282,6 +329,10 @@ provide let (>>) = (value: Int64, amount: Int64) => {
|
|
|
282
329
|
* @param y: The second value
|
|
283
330
|
* @returns `true` if the first value is equal to the second value or `false` otherwise
|
|
284
331
|
*
|
|
332
|
+
* @example
|
|
333
|
+
* use Int64.{ (==) }
|
|
334
|
+
* assert 1L == 1L
|
|
335
|
+
*
|
|
285
336
|
* @since v0.6.0
|
|
286
337
|
* @history v0.4.0: Originally named `eq`
|
|
287
338
|
*/
|
|
@@ -299,6 +350,10 @@ provide let (==) = (x: Int64, y: Int64) => {
|
|
|
299
350
|
* @param y: The second value
|
|
300
351
|
* @returns `true` if the first value is not equal to the second value or `false` otherwise
|
|
301
352
|
*
|
|
353
|
+
* @example
|
|
354
|
+
* use Int64.{ (!=) }
|
|
355
|
+
* assert 1L != 2L
|
|
356
|
+
*
|
|
302
357
|
* @since v0.6.0
|
|
303
358
|
* @history v0.4.0: Originally named `ne`
|
|
304
359
|
*/
|
|
@@ -315,6 +370,9 @@ provide let (!=) = (x: Int64, y: Int64) => {
|
|
|
315
370
|
* @param value: The value to inspect
|
|
316
371
|
* @returns `true` if the first value is equal to zero or `false` otherwise
|
|
317
372
|
*
|
|
373
|
+
* @example Int64.eqz(0L) == true
|
|
374
|
+
* @example Int64.eqz(1L) == false
|
|
375
|
+
*
|
|
318
376
|
* @since v0.4.0
|
|
319
377
|
*/
|
|
320
378
|
@unsafe
|
|
@@ -330,6 +388,10 @@ provide let eqz = (value: Int64) => {
|
|
|
330
388
|
* @param y: The second value
|
|
331
389
|
* @returns `true` if the first value is less than the second value or `false` otherwise
|
|
332
390
|
*
|
|
391
|
+
* @example
|
|
392
|
+
* use Int64.{ (<) }
|
|
393
|
+
* assert 1L < 2L
|
|
394
|
+
*
|
|
333
395
|
* @since v0.6.0
|
|
334
396
|
* @history v0.2.0: Originally named `lt`
|
|
335
397
|
*/
|
|
@@ -347,6 +409,10 @@ provide let (<) = (x: Int64, y: Int64) => {
|
|
|
347
409
|
* @param y: The second value
|
|
348
410
|
* @returns `true` if the first value is greater than the second value or `false` otherwise
|
|
349
411
|
*
|
|
412
|
+
* @example
|
|
413
|
+
* use Int64.{ (>) }
|
|
414
|
+
* assert 2L > 1L
|
|
415
|
+
*
|
|
350
416
|
* @since v0.6.0
|
|
351
417
|
* @history v0.2.0: Originally named `gt`
|
|
352
418
|
*/
|
|
@@ -364,6 +430,13 @@ provide let (>) = (x: Int64, y: Int64) => {
|
|
|
364
430
|
* @param y: The second value
|
|
365
431
|
* @returns `true` if the first value is less than or equal to the second value or `false` otherwise
|
|
366
432
|
*
|
|
433
|
+
* @example
|
|
434
|
+
* use Int64.{ (<=) }
|
|
435
|
+
* assert 1L <= 2L
|
|
436
|
+
* @example
|
|
437
|
+
* use Int64.{ (<=) }
|
|
438
|
+
* assert 1L <= 1L
|
|
439
|
+
*
|
|
367
440
|
* @since v0.6.0
|
|
368
441
|
* @history v0.2.0: Originally named `lte`
|
|
369
442
|
*/
|
|
@@ -381,6 +454,13 @@ provide let (<=) = (x: Int64, y: Int64) => {
|
|
|
381
454
|
* @param y: The second value
|
|
382
455
|
* @returns `true` if the first value is greater than or equal to the second value or `false` otherwise
|
|
383
456
|
*
|
|
457
|
+
* @example
|
|
458
|
+
* use Int64.{ (>=) }
|
|
459
|
+
* assert 2L >= 1L
|
|
460
|
+
* @example
|
|
461
|
+
* use Int64.{ (>=) }
|
|
462
|
+
* assert 1L >= 1L
|
|
463
|
+
*
|
|
384
464
|
* @since v0.6.0
|
|
385
465
|
* @history v0.2.0: Originally named `gte`
|
|
386
466
|
*/
|
|
@@ -397,6 +477,8 @@ provide let (>=) = (x: Int64, y: Int64) => {
|
|
|
397
477
|
* @param value: The given value
|
|
398
478
|
* @returns Containing the inverted bits of the given value
|
|
399
479
|
*
|
|
480
|
+
* @example Int64.lnot(-5L) == 4L
|
|
481
|
+
*
|
|
400
482
|
* @since v0.2.0
|
|
401
483
|
*/
|
|
402
484
|
@unsafe
|
|
@@ -413,6 +495,10 @@ provide let lnot = (value: Int64) => {
|
|
|
413
495
|
* @param y: The second operand
|
|
414
496
|
* @returns Containing a `1` in each bit position for which the corresponding bits of both operands are `1`
|
|
415
497
|
*
|
|
498
|
+
* @example
|
|
499
|
+
* use Int64.{ (&) }
|
|
500
|
+
* assert (3L & 4L) == 0L
|
|
501
|
+
*
|
|
416
502
|
* @since v0.6.0
|
|
417
503
|
* @history v0.2.0: Originally named `land`
|
|
418
504
|
*/
|
|
@@ -431,6 +517,10 @@ provide let (&) = (x: Int64, y: Int64) => {
|
|
|
431
517
|
* @param y: The second operand
|
|
432
518
|
* @returns Containing a `1` in each bit position for which the corresponding bits of either or both operands are `1`
|
|
433
519
|
*
|
|
520
|
+
* @example
|
|
521
|
+
* use Int64.{ (|) }
|
|
522
|
+
* assert (3L | 4L) == 7L
|
|
523
|
+
*
|
|
434
524
|
* @since v0.6.0
|
|
435
525
|
* @history v0.2.0: Originally named `lor`
|
|
436
526
|
*/
|
|
@@ -449,6 +539,10 @@ provide let (|) = (x: Int64, y: Int64) => {
|
|
|
449
539
|
* @param y: The second operand
|
|
450
540
|
* @returns Containing a `1` in each bit position for which the corresponding bits of either but not both operands are `1`
|
|
451
541
|
*
|
|
542
|
+
* @example
|
|
543
|
+
* use Int64.{ (^) }
|
|
544
|
+
* assert (3L ^ 5L) == 6L
|
|
545
|
+
*
|
|
452
546
|
* @since v0.6.0
|
|
453
547
|
* @history v0.2.0: Originally named `lxor`
|
|
454
548
|
*/
|
|
@@ -466,6 +560,9 @@ provide let (^) = (x: Int64, y: Int64) => {
|
|
|
466
560
|
* @param value: The value to inspect
|
|
467
561
|
* @returns The amount of leading zeros
|
|
468
562
|
*
|
|
563
|
+
* @example Int64.clz(1L) == 63L
|
|
564
|
+
* @example Int64.clz(4L) == 61L
|
|
565
|
+
*
|
|
469
566
|
* @since v0.4.0
|
|
470
567
|
*/
|
|
471
568
|
@unsafe
|
|
@@ -481,6 +578,9 @@ provide let clz = (value: Int64) => {
|
|
|
481
578
|
* @param value: The value to inspect
|
|
482
579
|
* @returns The amount of trailing zeros
|
|
483
580
|
*
|
|
581
|
+
* @example Int64.ctz(1L) == 0L
|
|
582
|
+
* @example Int64.ctz(4L) == 2L
|
|
583
|
+
*
|
|
484
584
|
* @since v0.4.0
|
|
485
585
|
*/
|
|
486
586
|
@unsafe
|
|
@@ -496,6 +596,9 @@ provide let ctz = (value: Int64) => {
|
|
|
496
596
|
* @param value: The value to inspect
|
|
497
597
|
* @returns The amount of 1-bits in its operand
|
|
498
598
|
*
|
|
599
|
+
* @example Int64.popcnt(1L) == 1L
|
|
600
|
+
* @example Int64.popcnt(3L) == 2L
|
|
601
|
+
*
|
|
499
602
|
* @since v0.4.0
|
|
500
603
|
*/
|
|
501
604
|
@unsafe
|
|
@@ -525,6 +628,10 @@ let rec expBySquaring = (y, x, n) => {
|
|
|
525
628
|
* @param power: The exponent number
|
|
526
629
|
* @returns The base raised to the given power
|
|
527
630
|
*
|
|
631
|
+
* @example
|
|
632
|
+
* from Int64 use { (**) }
|
|
633
|
+
* assert 2L ** 3L == 8L
|
|
634
|
+
*
|
|
528
635
|
* @since v0.6.0
|
|
529
636
|
*/
|
|
530
637
|
provide let (**) = (base, power) => {
|