@grain/stdlib 0.6.6 → 0.7.1
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 +67 -0
- package/LICENSE +1 -1
- package/README.md +2 -2
- package/array.gr +55 -7
- package/array.md +606 -560
- package/bigint.md +228 -228
- package/buffer.gr +85 -53
- package/buffer.md +442 -319
- package/bytes.gr +112 -35
- package/bytes.md +299 -219
- package/char.gr +201 -99
- package/char.md +447 -120
- package/exception.gr +11 -11
- package/exception.md +29 -4
- package/float32.gr +327 -3
- package/float32.md +698 -111
- package/float64.gr +320 -3
- package/float64.md +698 -111
- package/fs.gr +1082 -0
- package/fs.md +630 -0
- package/hash.gr +142 -88
- package/hash.md +105 -17
- package/int16.md +178 -178
- package/int32.gr +26 -5
- package/int32.md +266 -231
- package/int64.gr +27 -2
- package/int64.md +266 -231
- package/int8.md +178 -178
- package/json.gr +366 -51
- package/json.md +431 -15
- package/list.gr +328 -31
- package/list.md +759 -336
- package/map.gr +20 -12
- package/map.md +266 -260
- package/marshal.gr +41 -40
- package/marshal.md +14 -14
- package/number.gr +278 -35
- package/number.md +688 -269
- package/option.md +162 -162
- package/package.json +5 -3
- package/path.gr +48 -0
- package/path.md +180 -89
- package/pervasives.gr +2 -2
- package/pervasives.md +275 -275
- package/priorityqueue.gr +7 -7
- package/priorityqueue.md +131 -131
- package/queue.gr +183 -29
- package/queue.md +404 -148
- package/random.md +43 -43
- package/range.gr +4 -4
- package/range.md +42 -42
- package/rational.md +123 -123
- package/regex.gr +52 -51
- package/regex.md +102 -102
- package/result.md +118 -118
- package/runtime/atof/common.md +39 -39
- package/runtime/atof/decimal.gr +6 -6
- package/runtime/atof/decimal.md +14 -14
- package/runtime/atof/lemire.gr +5 -5
- package/runtime/atof/lemire.md +1 -1
- package/runtime/atof/parse.gr +16 -16
- package/runtime/atof/parse.md +2 -2
- package/runtime/atof/slow.md +1 -1
- package/runtime/atof/table.md +2 -2
- package/runtime/atoi/parse.gr +3 -3
- package/runtime/atoi/parse.md +1 -1
- package/runtime/bigint.gr +15 -47
- package/runtime/bigint.md +54 -60
- package/runtime/compare.gr +2 -2
- package/runtime/compare.md +8 -8
- package/runtime/dataStructures.md +211 -211
- package/runtime/debugPrint.gr +4 -1
- package/runtime/debugPrint.md +9 -9
- package/runtime/equal.gr +99 -77
- package/runtime/equal.md +8 -8
- package/runtime/exception.gr +62 -82
- package/runtime/exception.md +62 -11
- package/runtime/gc.gr +39 -45
- package/runtime/gc.md +4 -4
- package/runtime/malloc.gr +7 -7
- package/runtime/malloc.md +13 -13
- package/runtime/math/kernel/cos.gr +70 -0
- package/runtime/math/kernel/cos.md +14 -0
- package/runtime/math/kernel/sin.gr +65 -0
- package/runtime/math/kernel/sin.md +14 -0
- package/runtime/math/kernel/tan.gr +136 -0
- package/runtime/math/kernel/tan.md +14 -0
- package/runtime/math/rempio2.gr +244 -0
- package/runtime/math/rempio2.md +14 -0
- package/runtime/math/trig.gr +130 -0
- package/runtime/math/trig.md +28 -0
- package/runtime/math/umuldi.gr +26 -0
- package/runtime/math/umuldi.md +14 -0
- package/runtime/numberUtils.gr +29 -29
- package/runtime/numberUtils.md +12 -12
- package/runtime/numbers.gr +373 -381
- package/runtime/numbers.md +348 -342
- package/runtime/string.gr +37 -105
- package/runtime/string.md +20 -26
- package/runtime/unsafe/constants.md +24 -24
- package/runtime/unsafe/conv.md +19 -19
- package/runtime/unsafe/memory.gr +24 -20
- package/runtime/unsafe/memory.md +27 -7
- package/runtime/unsafe/offsets.gr +36 -0
- package/runtime/unsafe/offsets.md +88 -0
- package/runtime/unsafe/panic.gr +28 -0
- package/runtime/unsafe/panic.md +14 -0
- package/runtime/unsafe/tags.md +32 -32
- package/runtime/unsafe/wasmf32.md +28 -28
- package/runtime/unsafe/wasmf64.md +28 -28
- package/runtime/unsafe/wasmi32.md +47 -47
- package/runtime/unsafe/wasmi64.md +50 -50
- package/runtime/utf8.gr +189 -0
- package/runtime/utf8.md +117 -0
- package/runtime/wasi.gr +4 -2
- package/runtime/wasi.md +147 -147
- package/set.gr +18 -11
- package/set.md +253 -247
- package/stack.gr +171 -2
- package/stack.md +371 -89
- package/string.gr +352 -557
- package/string.md +298 -255
- package/uint16.md +170 -170
- package/uint32.gr +25 -4
- package/uint32.md +249 -214
- package/uint64.gr +25 -5
- package/uint64.md +249 -214
- package/uint8.md +170 -170
- package/uri.gr +57 -53
- package/uri.md +88 -89
- package/wasi/file.gr +67 -59
- package/wasi/file.md +308 -308
- package/wasi/process.md +26 -26
- package/wasi/random.md +12 -12
- package/wasi/time.md +16 -16
- package/runtime/utils/printing.gr +0 -60
- package/runtime/utils/printing.md +0 -26
package/bigint.md
CHANGED
|
@@ -37,22 +37,22 @@ No other changes yet.
|
|
|
37
37
|
</details>
|
|
38
38
|
|
|
39
39
|
```grain
|
|
40
|
-
fromNumber
|
|
40
|
+
fromNumber: (number: Number) => BigInt
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
Converts a Number to a BigInt.
|
|
44
44
|
|
|
45
45
|
Parameters:
|
|
46
46
|
|
|
47
|
-
|param|type|description|
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
| param | type | description |
|
|
48
|
+
| -------- | -------- | -------------------- |
|
|
49
|
+
| `number` | `Number` | The value to convert |
|
|
50
50
|
|
|
51
51
|
Returns:
|
|
52
52
|
|
|
53
|
-
|type|description|
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
| type | description |
|
|
54
|
+
| -------- | ---------------------------------- |
|
|
55
|
+
| `BigInt` | The Number represented as a BigInt |
|
|
56
56
|
|
|
57
57
|
### BigInt.**toNumber**
|
|
58
58
|
|
|
@@ -62,22 +62,22 @@ No other changes yet.
|
|
|
62
62
|
</details>
|
|
63
63
|
|
|
64
64
|
```grain
|
|
65
|
-
toNumber
|
|
65
|
+
toNumber: (num: BigInt) => Number
|
|
66
66
|
```
|
|
67
67
|
|
|
68
68
|
Converts a BigInt to a Number.
|
|
69
69
|
|
|
70
70
|
Parameters:
|
|
71
71
|
|
|
72
|
-
|param|type|description|
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
| param | type | description |
|
|
73
|
+
| ----- | -------- | -------------------- |
|
|
74
|
+
| `num` | `BigInt` | The value to convert |
|
|
75
75
|
|
|
76
76
|
Returns:
|
|
77
77
|
|
|
78
|
-
|type|description|
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
| type | description |
|
|
79
|
+
| -------- | ---------------------------------- |
|
|
80
|
+
| `Number` | The BigInt represented as a Number |
|
|
81
81
|
|
|
82
82
|
### BigInt.**incr**
|
|
83
83
|
|
|
@@ -87,22 +87,22 @@ No other changes yet.
|
|
|
87
87
|
</details>
|
|
88
88
|
|
|
89
89
|
```grain
|
|
90
|
-
incr
|
|
90
|
+
incr: (num: BigInt) => BigInt
|
|
91
91
|
```
|
|
92
92
|
|
|
93
93
|
Increments the value by one.
|
|
94
94
|
|
|
95
95
|
Parameters:
|
|
96
96
|
|
|
97
|
-
|param|type|description|
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
| param | type | description |
|
|
98
|
+
| ----- | -------- | ---------------------- |
|
|
99
|
+
| `num` | `BigInt` | The value to increment |
|
|
100
100
|
|
|
101
101
|
Returns:
|
|
102
102
|
|
|
103
|
-
|type|description|
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
| type | description |
|
|
104
|
+
| -------- | --------------------- |
|
|
105
|
+
| `BigInt` | The incremented value |
|
|
106
106
|
|
|
107
107
|
Examples:
|
|
108
108
|
|
|
@@ -122,22 +122,22 @@ No other changes yet.
|
|
|
122
122
|
</details>
|
|
123
123
|
|
|
124
124
|
```grain
|
|
125
|
-
decr
|
|
125
|
+
decr: (num: BigInt) => BigInt
|
|
126
126
|
```
|
|
127
127
|
|
|
128
128
|
Decrements the value by one.
|
|
129
129
|
|
|
130
130
|
Parameters:
|
|
131
131
|
|
|
132
|
-
|param|type|description|
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
| param | type | description |
|
|
133
|
+
| ----- | -------- | ---------------------- |
|
|
134
|
+
| `num` | `BigInt` | The value to decrement |
|
|
135
135
|
|
|
136
136
|
Returns:
|
|
137
137
|
|
|
138
|
-
|type|description|
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
| type | description |
|
|
139
|
+
| -------- | --------------------- |
|
|
140
|
+
| `BigInt` | The decremented value |
|
|
141
141
|
|
|
142
142
|
Examples:
|
|
143
143
|
|
|
@@ -157,22 +157,22 @@ No other changes yet.
|
|
|
157
157
|
</details>
|
|
158
158
|
|
|
159
159
|
```grain
|
|
160
|
-
neg
|
|
160
|
+
neg: (num: BigInt) => BigInt
|
|
161
161
|
```
|
|
162
162
|
|
|
163
163
|
Negates the given operand.
|
|
164
164
|
|
|
165
165
|
Parameters:
|
|
166
166
|
|
|
167
|
-
|param|type|description|
|
|
168
|
-
|
|
169
|
-
|
|
167
|
+
| param | type | description |
|
|
168
|
+
| ----- | -------- | ----------- |
|
|
169
|
+
| `num` | `BigInt` | The operand |
|
|
170
170
|
|
|
171
171
|
Returns:
|
|
172
172
|
|
|
173
|
-
|type|description|
|
|
174
|
-
|
|
175
|
-
|
|
173
|
+
| type | description |
|
|
174
|
+
| -------- | ------------------- |
|
|
175
|
+
| `BigInt` | The negated operand |
|
|
176
176
|
|
|
177
177
|
Examples:
|
|
178
178
|
|
|
@@ -192,22 +192,22 @@ No other changes yet.
|
|
|
192
192
|
</details>
|
|
193
193
|
|
|
194
194
|
```grain
|
|
195
|
-
abs
|
|
195
|
+
abs: (num: BigInt) => BigInt
|
|
196
196
|
```
|
|
197
197
|
|
|
198
198
|
Returns the absolute value of the given operand.
|
|
199
199
|
|
|
200
200
|
Parameters:
|
|
201
201
|
|
|
202
|
-
|param|type|description|
|
|
203
|
-
|
|
204
|
-
|
|
202
|
+
| param | type | description |
|
|
203
|
+
| ----- | -------- | ----------- |
|
|
204
|
+
| `num` | `BigInt` | The operand |
|
|
205
205
|
|
|
206
206
|
Returns:
|
|
207
207
|
|
|
208
|
-
|type|description|
|
|
209
|
-
|
|
210
|
-
|
|
208
|
+
| type | description |
|
|
209
|
+
| -------- | ---------------------------- |
|
|
210
|
+
| `BigInt` | The operand's absolute value |
|
|
211
211
|
|
|
212
212
|
Examples:
|
|
213
213
|
|
|
@@ -234,23 +234,23 @@ BigInt.abs(-1t) == 1t
|
|
|
234
234
|
</details>
|
|
235
235
|
|
|
236
236
|
```grain
|
|
237
|
-
(+)
|
|
237
|
+
(+): (num1: BigInt, num2: BigInt) => BigInt
|
|
238
238
|
```
|
|
239
239
|
|
|
240
240
|
Computes the sum of its operands.
|
|
241
241
|
|
|
242
242
|
Parameters:
|
|
243
243
|
|
|
244
|
-
|param|type|description|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
244
|
+
| param | type | description |
|
|
245
|
+
| ------ | -------- | ------------------ |
|
|
246
|
+
| `num1` | `BigInt` | The first operand |
|
|
247
|
+
| `num2` | `BigInt` | The second operand |
|
|
248
248
|
|
|
249
249
|
Returns:
|
|
250
250
|
|
|
251
|
-
|type|description|
|
|
252
|
-
|
|
253
|
-
|
|
251
|
+
| type | description |
|
|
252
|
+
| -------- | --------------------------- |
|
|
253
|
+
| `BigInt` | The sum of the two operands |
|
|
254
254
|
|
|
255
255
|
Examples:
|
|
256
256
|
|
|
@@ -274,23 +274,23 @@ assert 1t + 1t == 2t
|
|
|
274
274
|
</details>
|
|
275
275
|
|
|
276
276
|
```grain
|
|
277
|
-
(-)
|
|
277
|
+
(-): (num1: BigInt, num2: BigInt) => BigInt
|
|
278
278
|
```
|
|
279
279
|
|
|
280
280
|
Computes the difference of its operands.
|
|
281
281
|
|
|
282
282
|
Parameters:
|
|
283
283
|
|
|
284
|
-
|param|type|description|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
284
|
+
| param | type | description |
|
|
285
|
+
| ------ | -------- | ------------------ |
|
|
286
|
+
| `num1` | `BigInt` | The first operand |
|
|
287
|
+
| `num2` | `BigInt` | The second operand |
|
|
288
288
|
|
|
289
289
|
Returns:
|
|
290
290
|
|
|
291
|
-
|type|description|
|
|
292
|
-
|
|
293
|
-
|
|
291
|
+
| type | description |
|
|
292
|
+
| -------- | ---------------------------------- |
|
|
293
|
+
| `BigInt` | The difference of the two operands |
|
|
294
294
|
|
|
295
295
|
Examples:
|
|
296
296
|
|
|
@@ -314,23 +314,23 @@ assert 3t - 1t == 2t
|
|
|
314
314
|
</details>
|
|
315
315
|
|
|
316
316
|
```grain
|
|
317
|
-
(*)
|
|
317
|
+
(*): (num1: BigInt, num2: BigInt) => BigInt
|
|
318
318
|
```
|
|
319
319
|
|
|
320
320
|
Computes the product of its operands.
|
|
321
321
|
|
|
322
322
|
Parameters:
|
|
323
323
|
|
|
324
|
-
|param|type|description|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
324
|
+
| param | type | description |
|
|
325
|
+
| ------ | -------- | ------------------ |
|
|
326
|
+
| `num1` | `BigInt` | The first operand |
|
|
327
|
+
| `num2` | `BigInt` | The second operand |
|
|
328
328
|
|
|
329
329
|
Returns:
|
|
330
330
|
|
|
331
|
-
|type|description|
|
|
332
|
-
|
|
333
|
-
|
|
331
|
+
| type | description |
|
|
332
|
+
| -------- | ------------------------------- |
|
|
333
|
+
| `BigInt` | The product of the two operands |
|
|
334
334
|
|
|
335
335
|
Examples:
|
|
336
336
|
|
|
@@ -354,7 +354,7 @@ assert 3t * 3t == 9t
|
|
|
354
354
|
</details>
|
|
355
355
|
|
|
356
356
|
```grain
|
|
357
|
-
(/)
|
|
357
|
+
(/): (num1: BigInt, num2: BigInt) => BigInt
|
|
358
358
|
```
|
|
359
359
|
|
|
360
360
|
Computes the quotient of its operands using signed (truncated) division
|
|
@@ -362,16 +362,16 @@ Computes the quotient of its operands using signed (truncated) division
|
|
|
362
362
|
|
|
363
363
|
Parameters:
|
|
364
364
|
|
|
365
|
-
|param|type|description|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
365
|
+
| param | type | description |
|
|
366
|
+
| ------ | -------- | ------------------ |
|
|
367
|
+
| `num1` | `BigInt` | The first operand |
|
|
368
|
+
| `num2` | `BigInt` | The second operand |
|
|
369
369
|
|
|
370
370
|
Returns:
|
|
371
371
|
|
|
372
|
-
|type|description|
|
|
373
|
-
|
|
374
|
-
|
|
372
|
+
| type | description |
|
|
373
|
+
| -------- | ---------------------------- |
|
|
374
|
+
| `BigInt` | The quotient of its operands |
|
|
375
375
|
|
|
376
376
|
Examples:
|
|
377
377
|
|
|
@@ -388,7 +388,7 @@ No other changes yet.
|
|
|
388
388
|
</details>
|
|
389
389
|
|
|
390
390
|
```grain
|
|
391
|
-
rem
|
|
391
|
+
rem: (num1: BigInt, num2: BigInt) => BigInt
|
|
392
392
|
```
|
|
393
393
|
|
|
394
394
|
Computes the remainder of the division of its operands using signed (truncated) division
|
|
@@ -396,16 +396,16 @@ Computes the remainder of the division of its operands using signed (truncated)
|
|
|
396
396
|
|
|
397
397
|
Parameters:
|
|
398
398
|
|
|
399
|
-
|param|type|description|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
399
|
+
| param | type | description |
|
|
400
|
+
| ------ | -------- | ------------------ |
|
|
401
|
+
| `num1` | `BigInt` | The first operand |
|
|
402
|
+
| `num2` | `BigInt` | The second operand |
|
|
403
403
|
|
|
404
404
|
Returns:
|
|
405
405
|
|
|
406
|
-
|type|description|
|
|
407
|
-
|
|
408
|
-
|
|
406
|
+
| type | description |
|
|
407
|
+
| -------- | ----------------------------- |
|
|
408
|
+
| `BigInt` | The remainder of its operands |
|
|
409
409
|
|
|
410
410
|
Examples:
|
|
411
411
|
|
|
@@ -421,23 +421,23 @@ No other changes yet.
|
|
|
421
421
|
</details>
|
|
422
422
|
|
|
423
423
|
```grain
|
|
424
|
-
quotRem
|
|
424
|
+
quotRem: (num1: BigInt, num2: BigInt) => (BigInt, BigInt)
|
|
425
425
|
```
|
|
426
426
|
|
|
427
427
|
Computes the quotient and remainder of its operands using signed (truncated) division.
|
|
428
428
|
|
|
429
429
|
Parameters:
|
|
430
430
|
|
|
431
|
-
|param|type|description|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
431
|
+
| param | type | description |
|
|
432
|
+
| ------ | -------- | ------------------ |
|
|
433
|
+
| `num1` | `BigInt` | The first operand |
|
|
434
|
+
| `num2` | `BigInt` | The second operand |
|
|
435
435
|
|
|
436
436
|
Returns:
|
|
437
437
|
|
|
438
|
-
|type|description|
|
|
439
|
-
|
|
440
|
-
|
|
438
|
+
| type | description |
|
|
439
|
+
| ------------------ | ------------------------------------------ |
|
|
440
|
+
| `(BigInt, BigInt)` | The quotient and remainder of its operands |
|
|
441
441
|
|
|
442
442
|
Examples:
|
|
443
443
|
|
|
@@ -453,23 +453,23 @@ No other changes yet.
|
|
|
453
453
|
</details>
|
|
454
454
|
|
|
455
455
|
```grain
|
|
456
|
-
gcd
|
|
456
|
+
gcd: (num1: BigInt, num2: BigInt) => BigInt
|
|
457
457
|
```
|
|
458
458
|
|
|
459
459
|
Computes the greatest common divisior of the two operands.
|
|
460
460
|
|
|
461
461
|
Parameters:
|
|
462
462
|
|
|
463
|
-
|param|type|description|
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
463
|
+
| param | type | description |
|
|
464
|
+
| ------ | -------- | ------------------ |
|
|
465
|
+
| `num1` | `BigInt` | The first operand |
|
|
466
|
+
| `num2` | `BigInt` | The second operand |
|
|
467
467
|
|
|
468
468
|
Returns:
|
|
469
469
|
|
|
470
|
-
|type|description|
|
|
471
|
-
|
|
472
|
-
|
|
470
|
+
| type | description |
|
|
471
|
+
| -------- | ------------------------------------------- |
|
|
472
|
+
| `BigInt` | The greatest common divisor of its operands |
|
|
473
473
|
|
|
474
474
|
Examples:
|
|
475
475
|
|
|
@@ -492,23 +492,23 @@ BigInt.gcd(36t, 24t) == 12t
|
|
|
492
492
|
</details>
|
|
493
493
|
|
|
494
494
|
```grain
|
|
495
|
-
(<<)
|
|
495
|
+
(<<): (num: BigInt, places: Int32) => BigInt
|
|
496
496
|
```
|
|
497
497
|
|
|
498
498
|
Shifts the bits of the value left by the given number of bits.
|
|
499
499
|
|
|
500
500
|
Parameters:
|
|
501
501
|
|
|
502
|
-
|param|type|description|
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
502
|
+
| param | type | description |
|
|
503
|
+
| -------- | -------- | ------------------------------ |
|
|
504
|
+
| `num` | `BigInt` | The value to shift |
|
|
505
|
+
| `places` | `Int32` | The number of bits to shift by |
|
|
506
506
|
|
|
507
507
|
Returns:
|
|
508
508
|
|
|
509
|
-
|type|description|
|
|
510
|
-
|
|
511
|
-
|
|
509
|
+
| type | description |
|
|
510
|
+
| -------- | ----------------- |
|
|
511
|
+
| `BigInt` | The shifted value |
|
|
512
512
|
|
|
513
513
|
Examples:
|
|
514
514
|
|
|
@@ -532,23 +532,23 @@ assert (10t << 2l) == 40t
|
|
|
532
532
|
</details>
|
|
533
533
|
|
|
534
534
|
```grain
|
|
535
|
-
(>>)
|
|
535
|
+
(>>): (num: BigInt, places: Int32) => BigInt
|
|
536
536
|
```
|
|
537
537
|
|
|
538
538
|
Shifts the bits of the value right by the given number of bits, preserving the sign bit.
|
|
539
539
|
|
|
540
540
|
Parameters:
|
|
541
541
|
|
|
542
|
-
|param|type|description|
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
542
|
+
| param | type | description |
|
|
543
|
+
| -------- | -------- | ---------------------- |
|
|
544
|
+
| `num` | `BigInt` | The value to shift |
|
|
545
|
+
| `places` | `Int32` | The amount to shift by |
|
|
546
546
|
|
|
547
547
|
Returns:
|
|
548
548
|
|
|
549
|
-
|type|description|
|
|
550
|
-
|
|
551
|
-
|
|
549
|
+
| type | description |
|
|
550
|
+
| -------- | ----------------- |
|
|
551
|
+
| `BigInt` | The shifted value |
|
|
552
552
|
|
|
553
553
|
Examples:
|
|
554
554
|
|
|
@@ -565,22 +565,22 @@ No other changes yet.
|
|
|
565
565
|
</details>
|
|
566
566
|
|
|
567
567
|
```grain
|
|
568
|
-
eqz
|
|
568
|
+
eqz: (num: BigInt) => Bool
|
|
569
569
|
```
|
|
570
570
|
|
|
571
571
|
Checks if the given value is equal to zero.
|
|
572
572
|
|
|
573
573
|
Parameters:
|
|
574
574
|
|
|
575
|
-
|param|type|description|
|
|
576
|
-
|
|
577
|
-
|
|
575
|
+
| param | type | description |
|
|
576
|
+
| ----- | -------- | -------------------- |
|
|
577
|
+
| `num` | `BigInt` | The value to inspect |
|
|
578
578
|
|
|
579
579
|
Returns:
|
|
580
580
|
|
|
581
|
-
|type|description|
|
|
582
|
-
|
|
583
|
-
|
|
581
|
+
| type | description |
|
|
582
|
+
| ------ | --------------------------------------------------------------- |
|
|
583
|
+
| `Bool` | `true` if the first value is equal to zero or `false` otherwise |
|
|
584
584
|
|
|
585
585
|
Examples:
|
|
586
586
|
|
|
@@ -607,23 +607,23 @@ assert BigInt.eqz(1t) == false
|
|
|
607
607
|
</details>
|
|
608
608
|
|
|
609
609
|
```grain
|
|
610
|
-
(==)
|
|
610
|
+
(==): (num1: BigInt, num2: BigInt) => Bool
|
|
611
611
|
```
|
|
612
612
|
|
|
613
613
|
Checks if the first value is equal to the second value.
|
|
614
614
|
|
|
615
615
|
Parameters:
|
|
616
616
|
|
|
617
|
-
|param|type|description|
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
617
|
+
| param | type | description |
|
|
618
|
+
| ------ | -------- | ---------------- |
|
|
619
|
+
| `num1` | `BigInt` | The first value |
|
|
620
|
+
| `num2` | `BigInt` | The second value |
|
|
621
621
|
|
|
622
622
|
Returns:
|
|
623
623
|
|
|
624
|
-
|type|description|
|
|
625
|
-
|
|
626
|
-
|
|
624
|
+
| type | description |
|
|
625
|
+
| ------ | --------------------------------------------------------------------------- |
|
|
626
|
+
| `Bool` | `true` if the first value is equal to the second value or `false` otherwise |
|
|
627
627
|
|
|
628
628
|
Examples:
|
|
629
629
|
|
|
@@ -652,23 +652,23 @@ assert -10t == -10t
|
|
|
652
652
|
</details>
|
|
653
653
|
|
|
654
654
|
```grain
|
|
655
|
-
(!=)
|
|
655
|
+
(!=): (num1: BigInt, num2: BigInt) => Bool
|
|
656
656
|
```
|
|
657
657
|
|
|
658
658
|
Checks if the first value is not equal to the second value.
|
|
659
659
|
|
|
660
660
|
Parameters:
|
|
661
661
|
|
|
662
|
-
|param|type|description|
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
662
|
+
| param | type | description |
|
|
663
|
+
| ------ | -------- | ---------------- |
|
|
664
|
+
| `num1` | `BigInt` | The first value |
|
|
665
|
+
| `num2` | `BigInt` | The second value |
|
|
666
666
|
|
|
667
667
|
Returns:
|
|
668
668
|
|
|
669
|
-
|type|description|
|
|
670
|
-
|
|
671
|
-
|
|
669
|
+
| type | description |
|
|
670
|
+
| ------ | ------------------------------------------------------------------------------- |
|
|
671
|
+
| `Bool` | `true` if the first value is not equal to the second value or `false` otherwise |
|
|
672
672
|
|
|
673
673
|
Examples:
|
|
674
674
|
|
|
@@ -697,23 +697,23 @@ assert -10t != -20t
|
|
|
697
697
|
</details>
|
|
698
698
|
|
|
699
699
|
```grain
|
|
700
|
-
(<)
|
|
700
|
+
(<): (num1: BigInt, num2: BigInt) => Bool
|
|
701
701
|
```
|
|
702
702
|
|
|
703
703
|
Checks if the first value is less than the second value.
|
|
704
704
|
|
|
705
705
|
Parameters:
|
|
706
706
|
|
|
707
|
-
|param|type|description|
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
707
|
+
| param | type | description |
|
|
708
|
+
| ------ | -------- | ---------------- |
|
|
709
|
+
| `num1` | `BigInt` | The first value |
|
|
710
|
+
| `num2` | `BigInt` | The second value |
|
|
711
711
|
|
|
712
712
|
Returns:
|
|
713
713
|
|
|
714
|
-
|type|description|
|
|
715
|
-
|
|
716
|
-
|
|
714
|
+
| type | description |
|
|
715
|
+
| ------ | ---------------------------------------------------------------------------- |
|
|
716
|
+
| `Bool` | `true` if the first value is less than the second value or `false` otherwise |
|
|
717
717
|
|
|
718
718
|
Examples:
|
|
719
719
|
|
|
@@ -742,23 +742,23 @@ assert -10t < 0t
|
|
|
742
742
|
</details>
|
|
743
743
|
|
|
744
744
|
```grain
|
|
745
|
-
(<=)
|
|
745
|
+
(<=): (num1: BigInt, num2: BigInt) => Bool
|
|
746
746
|
```
|
|
747
747
|
|
|
748
748
|
Checks if the first value is less than or equal to the second value.
|
|
749
749
|
|
|
750
750
|
Parameters:
|
|
751
751
|
|
|
752
|
-
|param|type|description|
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
752
|
+
| param | type | description |
|
|
753
|
+
| ------ | -------- | ---------------- |
|
|
754
|
+
| `num1` | `BigInt` | The first value |
|
|
755
|
+
| `num2` | `BigInt` | The second value |
|
|
756
756
|
|
|
757
757
|
Returns:
|
|
758
758
|
|
|
759
|
-
|type|description|
|
|
760
|
-
|
|
761
|
-
|
|
759
|
+
| type | description |
|
|
760
|
+
| ------ | ---------------------------------------------------------------------------------------- |
|
|
761
|
+
| `Bool` | `true` if the first value is less than or equal to the second value or `false` otherwise |
|
|
762
762
|
|
|
763
763
|
Examples:
|
|
764
764
|
|
|
@@ -792,23 +792,23 @@ assert 2t <= 3t
|
|
|
792
792
|
</details>
|
|
793
793
|
|
|
794
794
|
```grain
|
|
795
|
-
(>)
|
|
795
|
+
(>): (num1: BigInt, num2: BigInt) => Bool
|
|
796
796
|
```
|
|
797
797
|
|
|
798
798
|
Checks if the first value is greater than the second value.
|
|
799
799
|
|
|
800
800
|
Parameters:
|
|
801
801
|
|
|
802
|
-
|param|type|description|
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
802
|
+
| param | type | description |
|
|
803
|
+
| ------ | -------- | ---------------- |
|
|
804
|
+
| `num1` | `BigInt` | The first value |
|
|
805
|
+
| `num2` | `BigInt` | The second value |
|
|
806
806
|
|
|
807
807
|
Returns:
|
|
808
808
|
|
|
809
|
-
|type|description|
|
|
810
|
-
|
|
811
|
-
|
|
809
|
+
| type | description |
|
|
810
|
+
| ------ | ------------------------------------------------------------------------------- |
|
|
811
|
+
| `Bool` | `true` if the first value is greater than the second value or `false` otherwise |
|
|
812
812
|
|
|
813
813
|
Examples:
|
|
814
814
|
|
|
@@ -837,23 +837,23 @@ assert 0t > -10t
|
|
|
837
837
|
</details>
|
|
838
838
|
|
|
839
839
|
```grain
|
|
840
|
-
(>=)
|
|
840
|
+
(>=): (num1: BigInt, num2: BigInt) => Bool
|
|
841
841
|
```
|
|
842
842
|
|
|
843
843
|
Checks if the first value is greater than or equal to the second value.
|
|
844
844
|
|
|
845
845
|
Parameters:
|
|
846
846
|
|
|
847
|
-
|param|type|description|
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
847
|
+
| param | type | description |
|
|
848
|
+
| ------ | -------- | ---------------- |
|
|
849
|
+
| `num1` | `BigInt` | The first value |
|
|
850
|
+
| `num2` | `BigInt` | The second value |
|
|
851
851
|
|
|
852
852
|
Returns:
|
|
853
853
|
|
|
854
|
-
|type|description|
|
|
855
|
-
|
|
856
|
-
|
|
854
|
+
| type | description |
|
|
855
|
+
| ------ | ------------------------------------------------------------------------------------------- |
|
|
856
|
+
| `Bool` | `true` if the first value is greater than or equal to the second value or `false` otherwise |
|
|
857
857
|
|
|
858
858
|
Examples:
|
|
859
859
|
|
|
@@ -880,22 +880,22 @@ No other changes yet.
|
|
|
880
880
|
</details>
|
|
881
881
|
|
|
882
882
|
```grain
|
|
883
|
-
lnot
|
|
883
|
+
lnot: (num: BigInt) => BigInt
|
|
884
884
|
```
|
|
885
885
|
|
|
886
886
|
Computes the bitwise NOT of the given value.
|
|
887
887
|
|
|
888
888
|
Parameters:
|
|
889
889
|
|
|
890
|
-
|param|type|description|
|
|
891
|
-
|
|
892
|
-
|
|
890
|
+
| param | type | description |
|
|
891
|
+
| ----- | -------- | --------------- |
|
|
892
|
+
| `num` | `BigInt` | The given value |
|
|
893
893
|
|
|
894
894
|
Returns:
|
|
895
895
|
|
|
896
|
-
|type|description|
|
|
897
|
-
|
|
898
|
-
|
|
896
|
+
| type | description |
|
|
897
|
+
| -------- | ----------------------------------------------- |
|
|
898
|
+
| `BigInt` | Containing the inverted bits of the given value |
|
|
899
899
|
|
|
900
900
|
Examples:
|
|
901
901
|
|
|
@@ -918,23 +918,23 @@ BigInt.lnot(91234t) == -91235t
|
|
|
918
918
|
</details>
|
|
919
919
|
|
|
920
920
|
```grain
|
|
921
|
-
(&)
|
|
921
|
+
(&): (num1: BigInt, num2: BigInt) => BigInt
|
|
922
922
|
```
|
|
923
923
|
|
|
924
924
|
Computes the bitwise AND (`&`) on the given operands.
|
|
925
925
|
|
|
926
926
|
Parameters:
|
|
927
927
|
|
|
928
|
-
|param|type|description|
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
928
|
+
| param | type | description |
|
|
929
|
+
| ------ | -------- | ------------------ |
|
|
930
|
+
| `num1` | `BigInt` | The first operand |
|
|
931
|
+
| `num2` | `BigInt` | The second operand |
|
|
932
932
|
|
|
933
933
|
Returns:
|
|
934
934
|
|
|
935
|
-
|type|description|
|
|
936
|
-
|
|
937
|
-
|
|
935
|
+
| type | description |
|
|
936
|
+
| -------- | ----------------------------------------------------------------------------------------------- |
|
|
937
|
+
| `BigInt` | Containing a `1` in each bit position for which the corresponding bits of both operands are `1` |
|
|
938
938
|
|
|
939
939
|
Examples:
|
|
940
940
|
|
|
@@ -958,23 +958,23 @@ assert (4t & 3t) == 0t
|
|
|
958
958
|
</details>
|
|
959
959
|
|
|
960
960
|
```grain
|
|
961
|
-
(|)
|
|
961
|
+
(|): (num1: BigInt, num2: BigInt) => BigInt
|
|
962
962
|
```
|
|
963
963
|
|
|
964
964
|
Computes the bitwise OR (`|`) on the given operands.
|
|
965
965
|
|
|
966
966
|
Parameters:
|
|
967
967
|
|
|
968
|
-
|param|type|description|
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
968
|
+
| param | type | description |
|
|
969
|
+
| ------ | -------- | ------------------ |
|
|
970
|
+
| `num1` | `BigInt` | The first operand |
|
|
971
|
+
| `num2` | `BigInt` | The second operand |
|
|
972
972
|
|
|
973
973
|
Returns:
|
|
974
974
|
|
|
975
|
-
|type|description|
|
|
976
|
-
|
|
977
|
-
|
|
975
|
+
| type | description |
|
|
976
|
+
| -------- | --------------------------------------------------------------------------------------------------------- |
|
|
977
|
+
| `BigInt` | Containing a `1` in each bit position for which the corresponding bits of either or both operands are `1` |
|
|
978
978
|
|
|
979
979
|
Examples:
|
|
980
980
|
|
|
@@ -998,23 +998,23 @@ assert (5t | 3t) == 7t
|
|
|
998
998
|
</details>
|
|
999
999
|
|
|
1000
1000
|
```grain
|
|
1001
|
-
(^)
|
|
1001
|
+
(^): (num1: BigInt, num2: BigInt) => BigInt
|
|
1002
1002
|
```
|
|
1003
1003
|
|
|
1004
1004
|
Computes the bitwise XOR (`^`) on the given operands.
|
|
1005
1005
|
|
|
1006
1006
|
Parameters:
|
|
1007
1007
|
|
|
1008
|
-
|param|type|description|
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1008
|
+
| param | type | description |
|
|
1009
|
+
| ------ | -------- | ------------------ |
|
|
1010
|
+
| `num1` | `BigInt` | The first operand |
|
|
1011
|
+
| `num2` | `BigInt` | The second operand |
|
|
1012
1012
|
|
|
1013
1013
|
Returns:
|
|
1014
1014
|
|
|
1015
|
-
|type|description|
|
|
1016
|
-
|
|
1017
|
-
|
|
1015
|
+
| type | description |
|
|
1016
|
+
| -------- | -------------------------------------------------------------------------------------------------------------- |
|
|
1017
|
+
| `BigInt` | Containing a `1` in each bit position for which the corresponding bits of either but not both operands are `1` |
|
|
1018
1018
|
|
|
1019
1019
|
Examples:
|
|
1020
1020
|
|
|
@@ -1031,7 +1031,7 @@ No other changes yet.
|
|
|
1031
1031
|
</details>
|
|
1032
1032
|
|
|
1033
1033
|
```grain
|
|
1034
|
-
clz
|
|
1034
|
+
clz: (num: BigInt) => Int32
|
|
1035
1035
|
```
|
|
1036
1036
|
|
|
1037
1037
|
Counts the number of leading zero bits in the value.
|
|
@@ -1039,15 +1039,15 @@ Will return the maximum integer for negative numbers.
|
|
|
1039
1039
|
|
|
1040
1040
|
Parameters:
|
|
1041
1041
|
|
|
1042
|
-
|param|type|description|
|
|
1043
|
-
|
|
1044
|
-
|
|
1042
|
+
| param | type | description |
|
|
1043
|
+
| ----- | -------- | -------------------- |
|
|
1044
|
+
| `num` | `BigInt` | The value to inspect |
|
|
1045
1045
|
|
|
1046
1046
|
Returns:
|
|
1047
1047
|
|
|
1048
|
-
|type|description|
|
|
1049
|
-
|
|
1050
|
-
|
|
1048
|
+
| type | description |
|
|
1049
|
+
| ------- | --------------------------- |
|
|
1050
|
+
| `Int32` | The amount of leading zeros |
|
|
1051
1051
|
|
|
1052
1052
|
Examples:
|
|
1053
1053
|
|
|
@@ -1063,22 +1063,22 @@ No other changes yet.
|
|
|
1063
1063
|
</details>
|
|
1064
1064
|
|
|
1065
1065
|
```grain
|
|
1066
|
-
ctz
|
|
1066
|
+
ctz: (num: BigInt) => Int64
|
|
1067
1067
|
```
|
|
1068
1068
|
|
|
1069
1069
|
Counts the number of trailing zero bits in the value.
|
|
1070
1070
|
|
|
1071
1071
|
Parameters:
|
|
1072
1072
|
|
|
1073
|
-
|param|type|description|
|
|
1074
|
-
|
|
1075
|
-
|
|
1073
|
+
| param | type | description |
|
|
1074
|
+
| ----- | -------- | -------------------- |
|
|
1075
|
+
| `num` | `BigInt` | The value to inspect |
|
|
1076
1076
|
|
|
1077
1077
|
Returns:
|
|
1078
1078
|
|
|
1079
|
-
|type|description|
|
|
1080
|
-
|
|
1081
|
-
|
|
1079
|
+
| type | description |
|
|
1080
|
+
| ------- | ---------------------------- |
|
|
1081
|
+
| `Int64` | The amount of trailing zeros |
|
|
1082
1082
|
|
|
1083
1083
|
Examples:
|
|
1084
1084
|
|
|
@@ -1094,7 +1094,7 @@ No other changes yet.
|
|
|
1094
1094
|
</details>
|
|
1095
1095
|
|
|
1096
1096
|
```grain
|
|
1097
|
-
popcnt
|
|
1097
|
+
popcnt: (num: BigInt) => Option<Int64>
|
|
1098
1098
|
```
|
|
1099
1099
|
|
|
1100
1100
|
Counts the number of bits set to `1` in the value, also known as a population count.
|
|
@@ -1102,15 +1102,15 @@ Will return the `None` if given a negative integer
|
|
|
1102
1102
|
|
|
1103
1103
|
Parameters:
|
|
1104
1104
|
|
|
1105
|
-
|param|type|description|
|
|
1106
|
-
|
|
1107
|
-
|
|
1105
|
+
| param | type | description |
|
|
1106
|
+
| ----- | -------- | -------------------- |
|
|
1107
|
+
| `num` | `BigInt` | The value to inspect |
|
|
1108
1108
|
|
|
1109
1109
|
Returns:
|
|
1110
1110
|
|
|
1111
|
-
|type|description|
|
|
1112
|
-
|
|
1113
|
-
|
|
1111
|
+
| type | description |
|
|
1112
|
+
| --------------- | ----------------------------------- |
|
|
1113
|
+
| `Option<Int64>` | The amount of 1-bits in its operand |
|
|
1114
1114
|
|
|
1115
1115
|
Examples:
|
|
1116
1116
|
|
|
@@ -1126,22 +1126,22 @@ No other changes yet.
|
|
|
1126
1126
|
</details>
|
|
1127
1127
|
|
|
1128
1128
|
```grain
|
|
1129
|
-
toString
|
|
1129
|
+
toString: (num: BigInt) => String
|
|
1130
1130
|
```
|
|
1131
1131
|
|
|
1132
1132
|
Converts the given operand to a string.
|
|
1133
1133
|
|
|
1134
1134
|
Parameters:
|
|
1135
1135
|
|
|
1136
|
-
|param|type|description|
|
|
1137
|
-
|
|
1138
|
-
|
|
1136
|
+
| param | type | description |
|
|
1137
|
+
| ----- | -------- | ----------- |
|
|
1138
|
+
| `num` | `BigInt` | The operand |
|
|
1139
1139
|
|
|
1140
1140
|
Returns:
|
|
1141
1141
|
|
|
1142
|
-
|type|description|
|
|
1143
|
-
|
|
1144
|
-
|
|
1142
|
+
| type | description |
|
|
1143
|
+
| -------- | ------------------------ |
|
|
1144
|
+
| `String` | The operand, as a string |
|
|
1145
1145
|
|
|
1146
1146
|
Examples:
|
|
1147
1147
|
|