@grain/stdlib 0.4.6 → 0.5.2
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 +93 -0
- package/array.gr +18 -18
- package/array.md +18 -18
- package/bigint.gr +497 -0
- package/bigint.md +811 -0
- package/buffer.gr +59 -223
- package/buffer.md +24 -17
- package/bytes.gr +100 -202
- package/bytes.md +19 -0
- package/char.gr +63 -133
- package/exception.gr +28 -2
- package/exception.md +43 -0
- package/float32.gr +76 -95
- package/float32.md +69 -30
- package/float64.gr +81 -95
- package/float64.md +69 -30
- package/hash.gr +37 -37
- package/int32.gr +152 -198
- package/int32.md +104 -0
- package/int64.gr +151 -197
- package/int64.md +104 -0
- package/list.gr +467 -70
- package/list.md +1141 -0
- package/map.gr +192 -7
- package/map.md +525 -0
- package/number.gr +111 -54
- package/number.md +100 -3
- package/option.md +1 -1
- package/package.json +3 -3
- package/pervasives.gr +499 -59
- package/pervasives.md +1116 -0
- package/queue.gr +4 -0
- package/queue.md +10 -0
- package/random.gr +196 -0
- package/random.md +179 -0
- package/regex.gr +1833 -842
- package/regex.md +11 -11
- package/result.md +1 -1
- package/runtime/bigint.gr +2045 -0
- package/runtime/bigint.md +326 -0
- package/runtime/dataStructures.gr +99 -278
- package/runtime/dataStructures.md +391 -0
- package/runtime/debug.md +6 -0
- package/runtime/equal.gr +5 -23
- package/runtime/equal.md +6 -0
- package/runtime/exception.md +30 -0
- package/runtime/gc.gr +20 -3
- package/runtime/gc.md +36 -0
- package/runtime/malloc.gr +13 -11
- package/runtime/malloc.md +55 -0
- package/runtime/numberUtils.gr +91 -41
- package/runtime/numberUtils.md +54 -0
- package/runtime/numbers.gr +1049 -391
- package/runtime/numbers.md +300 -0
- package/runtime/string.gr +136 -230
- package/runtime/string.md +24 -0
- package/runtime/stringUtils.gr +58 -38
- package/runtime/stringUtils.md +6 -0
- package/runtime/unsafe/constants.gr +17 -0
- package/runtime/unsafe/constants.md +72 -0
- package/runtime/unsafe/conv.md +71 -0
- package/runtime/unsafe/errors.md +204 -0
- package/runtime/unsafe/memory.md +54 -0
- package/runtime/unsafe/printWasm.md +24 -0
- package/runtime/unsafe/tags.gr +9 -8
- package/runtime/unsafe/tags.md +120 -0
- package/runtime/unsafe/wasmf32.md +168 -0
- package/runtime/unsafe/wasmf64.md +168 -0
- package/runtime/unsafe/wasmi32.md +282 -0
- package/runtime/unsafe/wasmi64.md +300 -0
- package/runtime/utils/printing.gr +62 -0
- package/runtime/utils/printing.md +18 -0
- package/runtime/wasi.gr +1 -1
- package/runtime/wasi.md +839 -0
- package/set.gr +17 -8
- package/set.md +24 -21
- package/stack.gr +3 -3
- package/stack.md +4 -6
- package/string.gr +194 -329
- package/string.md +3 -3
- package/sys/file.gr +245 -429
- package/sys/process.gr +27 -45
- package/sys/random.gr +47 -16
- package/sys/random.md +38 -0
- package/sys/time.gr +11 -27
package/bigint.md
ADDED
|
@@ -0,0 +1,811 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: BigInt
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Utilities for working with the BigInt type.
|
|
6
|
+
|
|
7
|
+
<details disabled>
|
|
8
|
+
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
9
|
+
No other changes yet.
|
|
10
|
+
</details>
|
|
11
|
+
|
|
12
|
+
```grain
|
|
13
|
+
import BigInt from "bigint"
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Conversions
|
|
17
|
+
|
|
18
|
+
Functions for converting between Numbers and the BigInt type.
|
|
19
|
+
|
|
20
|
+
### Bigint.**fromNumber**
|
|
21
|
+
|
|
22
|
+
<details disabled>
|
|
23
|
+
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
24
|
+
No other changes yet.
|
|
25
|
+
</details>
|
|
26
|
+
|
|
27
|
+
```grain
|
|
28
|
+
fromNumber : Number -> BigInt
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Converts a Number to a BigInt.
|
|
32
|
+
|
|
33
|
+
Parameters:
|
|
34
|
+
|
|
35
|
+
|param|type|description|
|
|
36
|
+
|-----|----|-----------|
|
|
37
|
+
|`number`|`Number`|The value to convert|
|
|
38
|
+
|
|
39
|
+
Returns:
|
|
40
|
+
|
|
41
|
+
|type|description|
|
|
42
|
+
|----|-----------|
|
|
43
|
+
|`BigInt`|The Number represented as a BigInt|
|
|
44
|
+
|
|
45
|
+
### Bigint.**toNumber**
|
|
46
|
+
|
|
47
|
+
<details disabled>
|
|
48
|
+
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
49
|
+
No other changes yet.
|
|
50
|
+
</details>
|
|
51
|
+
|
|
52
|
+
```grain
|
|
53
|
+
toNumber : BigInt -> Number
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Converts a BigInt to a Number.
|
|
57
|
+
|
|
58
|
+
Parameters:
|
|
59
|
+
|
|
60
|
+
|param|type|description|
|
|
61
|
+
|-----|----|-----------|
|
|
62
|
+
|`num`|`BigInt`|The value to convert|
|
|
63
|
+
|
|
64
|
+
Returns:
|
|
65
|
+
|
|
66
|
+
|type|description|
|
|
67
|
+
|----|-----------|
|
|
68
|
+
|`Number`|The BigInt represented as a Number|
|
|
69
|
+
|
|
70
|
+
## Operations
|
|
71
|
+
|
|
72
|
+
Mathematical operations for BigInt values.
|
|
73
|
+
|
|
74
|
+
### Bigint.**incr**
|
|
75
|
+
|
|
76
|
+
<details disabled>
|
|
77
|
+
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
78
|
+
No other changes yet.
|
|
79
|
+
</details>
|
|
80
|
+
|
|
81
|
+
```grain
|
|
82
|
+
incr : BigInt -> BigInt
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Increments the value by one.
|
|
86
|
+
|
|
87
|
+
Parameters:
|
|
88
|
+
|
|
89
|
+
|param|type|description|
|
|
90
|
+
|-----|----|-----------|
|
|
91
|
+
|`num`|`BigInt`|The value to increment|
|
|
92
|
+
|
|
93
|
+
Returns:
|
|
94
|
+
|
|
95
|
+
|type|description|
|
|
96
|
+
|----|-----------|
|
|
97
|
+
|`BigInt`|The incremented value|
|
|
98
|
+
|
|
99
|
+
### Bigint.**decr**
|
|
100
|
+
|
|
101
|
+
<details disabled>
|
|
102
|
+
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
103
|
+
No other changes yet.
|
|
104
|
+
</details>
|
|
105
|
+
|
|
106
|
+
```grain
|
|
107
|
+
decr : BigInt -> BigInt
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Decrements the value by one.
|
|
111
|
+
|
|
112
|
+
Parameters:
|
|
113
|
+
|
|
114
|
+
|param|type|description|
|
|
115
|
+
|-----|----|-----------|
|
|
116
|
+
|`num`|`BigInt`|The value to decrement|
|
|
117
|
+
|
|
118
|
+
Returns:
|
|
119
|
+
|
|
120
|
+
|type|description|
|
|
121
|
+
|----|-----------|
|
|
122
|
+
|`BigInt`|The decremented value|
|
|
123
|
+
|
|
124
|
+
### Bigint.**neg**
|
|
125
|
+
|
|
126
|
+
<details disabled>
|
|
127
|
+
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
128
|
+
No other changes yet.
|
|
129
|
+
</details>
|
|
130
|
+
|
|
131
|
+
```grain
|
|
132
|
+
neg : BigInt -> BigInt
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Negates the given operand.
|
|
136
|
+
|
|
137
|
+
Parameters:
|
|
138
|
+
|
|
139
|
+
|param|type|description|
|
|
140
|
+
|-----|----|-----------|
|
|
141
|
+
|`num`|`BigInt`|The operand|
|
|
142
|
+
|
|
143
|
+
Returns:
|
|
144
|
+
|
|
145
|
+
|type|description|
|
|
146
|
+
|----|-----------|
|
|
147
|
+
|`BigInt`|The negated operand|
|
|
148
|
+
|
|
149
|
+
### Bigint.**abs**
|
|
150
|
+
|
|
151
|
+
<details disabled>
|
|
152
|
+
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
153
|
+
No other changes yet.
|
|
154
|
+
</details>
|
|
155
|
+
|
|
156
|
+
```grain
|
|
157
|
+
abs : BigInt -> BigInt
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Returns the absolute value of the given operand.
|
|
161
|
+
|
|
162
|
+
Parameters:
|
|
163
|
+
|
|
164
|
+
|param|type|description|
|
|
165
|
+
|-----|----|-----------|
|
|
166
|
+
|`num`|`BigInt`|The operand|
|
|
167
|
+
|
|
168
|
+
Returns:
|
|
169
|
+
|
|
170
|
+
|type|description|
|
|
171
|
+
|----|-----------|
|
|
172
|
+
|`BigInt`|The operand's absolute value|
|
|
173
|
+
|
|
174
|
+
### Bigint.**add**
|
|
175
|
+
|
|
176
|
+
<details disabled>
|
|
177
|
+
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
178
|
+
No other changes yet.
|
|
179
|
+
</details>
|
|
180
|
+
|
|
181
|
+
```grain
|
|
182
|
+
add : (BigInt, BigInt) -> BigInt
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Computes the sum of its operands.
|
|
186
|
+
|
|
187
|
+
Parameters:
|
|
188
|
+
|
|
189
|
+
|param|type|description|
|
|
190
|
+
|-----|----|-----------|
|
|
191
|
+
|`num1`|`BigInt`|The first operand|
|
|
192
|
+
|`num2`|`BigInt`|The second operand|
|
|
193
|
+
|
|
194
|
+
Returns:
|
|
195
|
+
|
|
196
|
+
|type|description|
|
|
197
|
+
|----|-----------|
|
|
198
|
+
|`BigInt`|The sum of the two operands|
|
|
199
|
+
|
|
200
|
+
### Bigint.**sub**
|
|
201
|
+
|
|
202
|
+
<details disabled>
|
|
203
|
+
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
204
|
+
No other changes yet.
|
|
205
|
+
</details>
|
|
206
|
+
|
|
207
|
+
```grain
|
|
208
|
+
sub : (BigInt, BigInt) -> BigInt
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Computes the difference of its operands.
|
|
212
|
+
|
|
213
|
+
Parameters:
|
|
214
|
+
|
|
215
|
+
|param|type|description|
|
|
216
|
+
|-----|----|-----------|
|
|
217
|
+
|`num1`|`BigInt`|The first operand|
|
|
218
|
+
|`num2`|`BigInt`|The second operand|
|
|
219
|
+
|
|
220
|
+
Returns:
|
|
221
|
+
|
|
222
|
+
|type|description|
|
|
223
|
+
|----|-----------|
|
|
224
|
+
|`BigInt`|The difference of the two operands|
|
|
225
|
+
|
|
226
|
+
### Bigint.**mul**
|
|
227
|
+
|
|
228
|
+
<details disabled>
|
|
229
|
+
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
230
|
+
No other changes yet.
|
|
231
|
+
</details>
|
|
232
|
+
|
|
233
|
+
```grain
|
|
234
|
+
mul : (BigInt, BigInt) -> BigInt
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
Computes the product of its operands.
|
|
238
|
+
|
|
239
|
+
Parameters:
|
|
240
|
+
|
|
241
|
+
|param|type|description|
|
|
242
|
+
|-----|----|-----------|
|
|
243
|
+
|`num1`|`BigInt`|The first operand|
|
|
244
|
+
|`num2`|`BigInt`|The second operand|
|
|
245
|
+
|
|
246
|
+
Returns:
|
|
247
|
+
|
|
248
|
+
|type|description|
|
|
249
|
+
|----|-----------|
|
|
250
|
+
|`BigInt`|The product of the two operands|
|
|
251
|
+
|
|
252
|
+
### Bigint.**div**
|
|
253
|
+
|
|
254
|
+
<details disabled>
|
|
255
|
+
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
256
|
+
No other changes yet.
|
|
257
|
+
</details>
|
|
258
|
+
|
|
259
|
+
```grain
|
|
260
|
+
div : (BigInt, BigInt) -> BigInt
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
Computes the quotient of its operands using signed (truncated) division
|
|
264
|
+
(in which the quotient is always rounded towards zero).
|
|
265
|
+
|
|
266
|
+
Parameters:
|
|
267
|
+
|
|
268
|
+
|param|type|description|
|
|
269
|
+
|-----|----|-----------|
|
|
270
|
+
|`num1`|`BigInt`|The first operand|
|
|
271
|
+
|`num2`|`BigInt`|The second operand|
|
|
272
|
+
|
|
273
|
+
Returns:
|
|
274
|
+
|
|
275
|
+
|type|description|
|
|
276
|
+
|----|-----------|
|
|
277
|
+
|`BigInt`|The quotient of its operands|
|
|
278
|
+
|
|
279
|
+
### Bigint.**rem**
|
|
280
|
+
|
|
281
|
+
<details disabled>
|
|
282
|
+
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
283
|
+
No other changes yet.
|
|
284
|
+
</details>
|
|
285
|
+
|
|
286
|
+
```grain
|
|
287
|
+
rem : (BigInt, BigInt) -> BigInt
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
Computes the remainder of the division of its operands using signed (truncated) division
|
|
291
|
+
(in which the quotient is always rounded towards zero).
|
|
292
|
+
|
|
293
|
+
Parameters:
|
|
294
|
+
|
|
295
|
+
|param|type|description|
|
|
296
|
+
|-----|----|-----------|
|
|
297
|
+
|`num1`|`BigInt`|The first operand|
|
|
298
|
+
|`num2`|`BigInt`|The second operand|
|
|
299
|
+
|
|
300
|
+
Returns:
|
|
301
|
+
|
|
302
|
+
|type|description|
|
|
303
|
+
|----|-----------|
|
|
304
|
+
|`BigInt`|The remainder of its operands|
|
|
305
|
+
|
|
306
|
+
### Bigint.**quotRem**
|
|
307
|
+
|
|
308
|
+
<details disabled>
|
|
309
|
+
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
310
|
+
No other changes yet.
|
|
311
|
+
</details>
|
|
312
|
+
|
|
313
|
+
```grain
|
|
314
|
+
quotRem : (BigInt, BigInt) -> (BigInt, BigInt)
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
Computes the quotient and remainder of its operands using signed (truncated) division.
|
|
318
|
+
|
|
319
|
+
Parameters:
|
|
320
|
+
|
|
321
|
+
|param|type|description|
|
|
322
|
+
|-----|----|-----------|
|
|
323
|
+
|`num1`|`BigInt`|The first operand|
|
|
324
|
+
|`num2`|`BigInt`|The second operand|
|
|
325
|
+
|
|
326
|
+
Returns:
|
|
327
|
+
|
|
328
|
+
|type|description|
|
|
329
|
+
|----|-----------|
|
|
330
|
+
|`(BigInt, BigInt)`|The quotient and remainder of its operands|
|
|
331
|
+
|
|
332
|
+
### Bigint.**gcd**
|
|
333
|
+
|
|
334
|
+
<details disabled>
|
|
335
|
+
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
336
|
+
No other changes yet.
|
|
337
|
+
</details>
|
|
338
|
+
|
|
339
|
+
```grain
|
|
340
|
+
gcd : (BigInt, BigInt) -> BigInt
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
Computes the greatest common divisior of the two operands.
|
|
344
|
+
|
|
345
|
+
Parameters:
|
|
346
|
+
|
|
347
|
+
|param|type|description|
|
|
348
|
+
|-----|----|-----------|
|
|
349
|
+
|`num1`|`BigInt`|The first operand|
|
|
350
|
+
|`num2`|`BigInt`|The second operand|
|
|
351
|
+
|
|
352
|
+
Returns:
|
|
353
|
+
|
|
354
|
+
|type|description|
|
|
355
|
+
|----|-----------|
|
|
356
|
+
|`BigInt`|The greatest common divisor of its operands|
|
|
357
|
+
|
|
358
|
+
## Bitwise operations
|
|
359
|
+
|
|
360
|
+
Functions for operating on bits of BigInt values.
|
|
361
|
+
|
|
362
|
+
### Bigint.**shl**
|
|
363
|
+
|
|
364
|
+
<details disabled>
|
|
365
|
+
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
366
|
+
No other changes yet.
|
|
367
|
+
</details>
|
|
368
|
+
|
|
369
|
+
```grain
|
|
370
|
+
shl : (BigInt, Int32) -> BigInt
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
Shifts the bits of the value left by the given number of bits.
|
|
374
|
+
|
|
375
|
+
Parameters:
|
|
376
|
+
|
|
377
|
+
|param|type|description|
|
|
378
|
+
|-----|----|-----------|
|
|
379
|
+
|`num`|`BigInt`|The value to shift|
|
|
380
|
+
|`places`|`Int32`|The number of bits to shift by|
|
|
381
|
+
|
|
382
|
+
Returns:
|
|
383
|
+
|
|
384
|
+
|type|description|
|
|
385
|
+
|----|-----------|
|
|
386
|
+
|`BigInt`|The shifted value|
|
|
387
|
+
|
|
388
|
+
### Bigint.**shr**
|
|
389
|
+
|
|
390
|
+
<details disabled>
|
|
391
|
+
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
392
|
+
No other changes yet.
|
|
393
|
+
</details>
|
|
394
|
+
|
|
395
|
+
```grain
|
|
396
|
+
shr : (BigInt, Int32) -> BigInt
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
Shifts the bits of the value right by the given number of bits, preserving the sign bit.
|
|
400
|
+
|
|
401
|
+
Parameters:
|
|
402
|
+
|
|
403
|
+
|param|type|description|
|
|
404
|
+
|-----|----|-----------|
|
|
405
|
+
|`num`|`BigInt`|The value to shift|
|
|
406
|
+
|`places`|`Int32`|The amount to shift by|
|
|
407
|
+
|
|
408
|
+
Returns:
|
|
409
|
+
|
|
410
|
+
|type|description|
|
|
411
|
+
|----|-----------|
|
|
412
|
+
|`BigInt`|The shifted value|
|
|
413
|
+
|
|
414
|
+
## Comparisons
|
|
415
|
+
|
|
416
|
+
Functions for comparing BigInt values.
|
|
417
|
+
|
|
418
|
+
### Bigint.**eqz**
|
|
419
|
+
|
|
420
|
+
<details disabled>
|
|
421
|
+
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
422
|
+
No other changes yet.
|
|
423
|
+
</details>
|
|
424
|
+
|
|
425
|
+
```grain
|
|
426
|
+
eqz : BigInt -> Bool
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
Checks if the given value is equal to zero.
|
|
430
|
+
|
|
431
|
+
Parameters:
|
|
432
|
+
|
|
433
|
+
|param|type|description|
|
|
434
|
+
|-----|----|-----------|
|
|
435
|
+
|`num`|`BigInt`|The value to inspect|
|
|
436
|
+
|
|
437
|
+
Returns:
|
|
438
|
+
|
|
439
|
+
|type|description|
|
|
440
|
+
|----|-----------|
|
|
441
|
+
|`Bool`|`true` if the first value is equal to zero or `false` otherwise|
|
|
442
|
+
|
|
443
|
+
### Bigint.**eq**
|
|
444
|
+
|
|
445
|
+
<details disabled>
|
|
446
|
+
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
447
|
+
No other changes yet.
|
|
448
|
+
</details>
|
|
449
|
+
|
|
450
|
+
```grain
|
|
451
|
+
eq : (BigInt, BigInt) -> Bool
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
Checks if the first value is equal to the second value.
|
|
455
|
+
|
|
456
|
+
Parameters:
|
|
457
|
+
|
|
458
|
+
|param|type|description|
|
|
459
|
+
|-----|----|-----------|
|
|
460
|
+
|`num1`|`BigInt`|The first value|
|
|
461
|
+
|`num2`|`BigInt`|The second value|
|
|
462
|
+
|
|
463
|
+
Returns:
|
|
464
|
+
|
|
465
|
+
|type|description|
|
|
466
|
+
|----|-----------|
|
|
467
|
+
|`Bool`|`true` if the first value is equal to the second value or `false` otherwise|
|
|
468
|
+
|
|
469
|
+
### Bigint.**ne**
|
|
470
|
+
|
|
471
|
+
<details disabled>
|
|
472
|
+
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
473
|
+
No other changes yet.
|
|
474
|
+
</details>
|
|
475
|
+
|
|
476
|
+
```grain
|
|
477
|
+
ne : (BigInt, BigInt) -> Bool
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
Checks if the first value is not equal to the second value.
|
|
481
|
+
|
|
482
|
+
Parameters:
|
|
483
|
+
|
|
484
|
+
|param|type|description|
|
|
485
|
+
|-----|----|-----------|
|
|
486
|
+
|`num1`|`BigInt`|The first value|
|
|
487
|
+
|`num2`|`BigInt`|The second value|
|
|
488
|
+
|
|
489
|
+
Returns:
|
|
490
|
+
|
|
491
|
+
|type|description|
|
|
492
|
+
|----|-----------|
|
|
493
|
+
|`Bool`|`true` if the first value is not equal to the second value or `false` otherwise|
|
|
494
|
+
|
|
495
|
+
### Bigint.**lt**
|
|
496
|
+
|
|
497
|
+
<details disabled>
|
|
498
|
+
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
499
|
+
No other changes yet.
|
|
500
|
+
</details>
|
|
501
|
+
|
|
502
|
+
```grain
|
|
503
|
+
lt : (BigInt, BigInt) -> Bool
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
Checks if the first value is less than the second value.
|
|
507
|
+
|
|
508
|
+
Parameters:
|
|
509
|
+
|
|
510
|
+
|param|type|description|
|
|
511
|
+
|-----|----|-----------|
|
|
512
|
+
|`num1`|`BigInt`|The first value|
|
|
513
|
+
|`num2`|`BigInt`|The second value|
|
|
514
|
+
|
|
515
|
+
Returns:
|
|
516
|
+
|
|
517
|
+
|type|description|
|
|
518
|
+
|----|-----------|
|
|
519
|
+
|`Bool`|`true` if the first value is less than the second value or `false` otherwise|
|
|
520
|
+
|
|
521
|
+
### Bigint.**lte**
|
|
522
|
+
|
|
523
|
+
<details disabled>
|
|
524
|
+
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
525
|
+
No other changes yet.
|
|
526
|
+
</details>
|
|
527
|
+
|
|
528
|
+
```grain
|
|
529
|
+
lte : (BigInt, BigInt) -> Bool
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
Checks if the first value is less than or equal to the second value.
|
|
533
|
+
|
|
534
|
+
Parameters:
|
|
535
|
+
|
|
536
|
+
|param|type|description|
|
|
537
|
+
|-----|----|-----------|
|
|
538
|
+
|`num1`|`BigInt`|The first value|
|
|
539
|
+
|`num2`|`BigInt`|The second value|
|
|
540
|
+
|
|
541
|
+
Returns:
|
|
542
|
+
|
|
543
|
+
|type|description|
|
|
544
|
+
|----|-----------|
|
|
545
|
+
|`Bool`|`true` if the first value is less than or equal to the second value or `false` otherwise|
|
|
546
|
+
|
|
547
|
+
### Bigint.**gt**
|
|
548
|
+
|
|
549
|
+
<details disabled>
|
|
550
|
+
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
551
|
+
No other changes yet.
|
|
552
|
+
</details>
|
|
553
|
+
|
|
554
|
+
```grain
|
|
555
|
+
gt : (BigInt, BigInt) -> Bool
|
|
556
|
+
```
|
|
557
|
+
|
|
558
|
+
Checks if the first value is greater than the second value.
|
|
559
|
+
|
|
560
|
+
Parameters:
|
|
561
|
+
|
|
562
|
+
|param|type|description|
|
|
563
|
+
|-----|----|-----------|
|
|
564
|
+
|`num1`|`BigInt`|The first value|
|
|
565
|
+
|`num2`|`BigInt`|The second value|
|
|
566
|
+
|
|
567
|
+
Returns:
|
|
568
|
+
|
|
569
|
+
|type|description|
|
|
570
|
+
|----|-----------|
|
|
571
|
+
|`Bool`|`true` if the first value is greater than the second value or `false` otherwise|
|
|
572
|
+
|
|
573
|
+
### Bigint.**gte**
|
|
574
|
+
|
|
575
|
+
<details disabled>
|
|
576
|
+
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
577
|
+
No other changes yet.
|
|
578
|
+
</details>
|
|
579
|
+
|
|
580
|
+
```grain
|
|
581
|
+
gte : (BigInt, BigInt) -> Bool
|
|
582
|
+
```
|
|
583
|
+
|
|
584
|
+
Checks if the first value is greater than or equal to the second value.
|
|
585
|
+
|
|
586
|
+
Parameters:
|
|
587
|
+
|
|
588
|
+
|param|type|description|
|
|
589
|
+
|-----|----|-----------|
|
|
590
|
+
|`num1`|`BigInt`|The first value|
|
|
591
|
+
|`num2`|`BigInt`|The second value|
|
|
592
|
+
|
|
593
|
+
Returns:
|
|
594
|
+
|
|
595
|
+
|type|description|
|
|
596
|
+
|----|-----------|
|
|
597
|
+
|`Bool`|`true` if the first value is greater than or equal to the second value or `false` otherwise|
|
|
598
|
+
|
|
599
|
+
## Bitwise logic
|
|
600
|
+
|
|
601
|
+
Boolean operations on the bits of BigInt values.
|
|
602
|
+
|
|
603
|
+
### Bigint.**lnot**
|
|
604
|
+
|
|
605
|
+
<details disabled>
|
|
606
|
+
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
607
|
+
No other changes yet.
|
|
608
|
+
</details>
|
|
609
|
+
|
|
610
|
+
```grain
|
|
611
|
+
lnot : BigInt -> BigInt
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
Computes the bitwise NOT of the given value.
|
|
615
|
+
|
|
616
|
+
Parameters:
|
|
617
|
+
|
|
618
|
+
|param|type|description|
|
|
619
|
+
|-----|----|-----------|
|
|
620
|
+
|`num`|`BigInt`|The given value|
|
|
621
|
+
|
|
622
|
+
Returns:
|
|
623
|
+
|
|
624
|
+
|type|description|
|
|
625
|
+
|----|-----------|
|
|
626
|
+
|`BigInt`|Containing the inverted bits of the given value|
|
|
627
|
+
|
|
628
|
+
### Bigint.**land**
|
|
629
|
+
|
|
630
|
+
<details disabled>
|
|
631
|
+
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
632
|
+
No other changes yet.
|
|
633
|
+
</details>
|
|
634
|
+
|
|
635
|
+
```grain
|
|
636
|
+
land : (BigInt, BigInt) -> BigInt
|
|
637
|
+
```
|
|
638
|
+
|
|
639
|
+
Computes the bitwise AND (`&`) on the given operands.
|
|
640
|
+
|
|
641
|
+
Parameters:
|
|
642
|
+
|
|
643
|
+
|param|type|description|
|
|
644
|
+
|-----|----|-----------|
|
|
645
|
+
|`num1`|`BigInt`|The first operand|
|
|
646
|
+
|`num2`|`BigInt`|The second operand|
|
|
647
|
+
|
|
648
|
+
Returns:
|
|
649
|
+
|
|
650
|
+
|type|description|
|
|
651
|
+
|----|-----------|
|
|
652
|
+
|`BigInt`|Containing a `1` in each bit position for which the corresponding bits of both operands are `1`|
|
|
653
|
+
|
|
654
|
+
### Bigint.**lor**
|
|
655
|
+
|
|
656
|
+
<details disabled>
|
|
657
|
+
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
658
|
+
No other changes yet.
|
|
659
|
+
</details>
|
|
660
|
+
|
|
661
|
+
```grain
|
|
662
|
+
lor : (BigInt, BigInt) -> BigInt
|
|
663
|
+
```
|
|
664
|
+
|
|
665
|
+
Computes the bitwise OR (`|`) on the given operands.
|
|
666
|
+
|
|
667
|
+
Parameters:
|
|
668
|
+
|
|
669
|
+
|param|type|description|
|
|
670
|
+
|-----|----|-----------|
|
|
671
|
+
|`num1`|`BigInt`|The first operand|
|
|
672
|
+
|`num2`|`BigInt`|The second operand|
|
|
673
|
+
|
|
674
|
+
Returns:
|
|
675
|
+
|
|
676
|
+
|type|description|
|
|
677
|
+
|----|-----------|
|
|
678
|
+
|`BigInt`|Containing a `1` in each bit position for which the corresponding bits of either or both operands are `1`|
|
|
679
|
+
|
|
680
|
+
### Bigint.**lxor**
|
|
681
|
+
|
|
682
|
+
<details disabled>
|
|
683
|
+
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
684
|
+
No other changes yet.
|
|
685
|
+
</details>
|
|
686
|
+
|
|
687
|
+
```grain
|
|
688
|
+
lxor : (BigInt, BigInt) -> BigInt
|
|
689
|
+
```
|
|
690
|
+
|
|
691
|
+
Computes the bitwise XOR (`^`) on the given operands.
|
|
692
|
+
|
|
693
|
+
Parameters:
|
|
694
|
+
|
|
695
|
+
|param|type|description|
|
|
696
|
+
|-----|----|-----------|
|
|
697
|
+
|`num1`|`BigInt`|The first operand|
|
|
698
|
+
|`num2`|`BigInt`|The second operand|
|
|
699
|
+
|
|
700
|
+
Returns:
|
|
701
|
+
|
|
702
|
+
|type|description|
|
|
703
|
+
|----|-----------|
|
|
704
|
+
|`BigInt`|Containing a `1` in each bit position for which the corresponding bits of either but not both operands are `1`|
|
|
705
|
+
|
|
706
|
+
### Bigint.**clz**
|
|
707
|
+
|
|
708
|
+
<details disabled>
|
|
709
|
+
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
710
|
+
No other changes yet.
|
|
711
|
+
</details>
|
|
712
|
+
|
|
713
|
+
```grain
|
|
714
|
+
clz : BigInt -> Int32
|
|
715
|
+
```
|
|
716
|
+
|
|
717
|
+
Counts the number of leading zero bits in the value.
|
|
718
|
+
Will return the maximum integer for negative numbers.
|
|
719
|
+
|
|
720
|
+
Parameters:
|
|
721
|
+
|
|
722
|
+
|param|type|description|
|
|
723
|
+
|-----|----|-----------|
|
|
724
|
+
|`num`|`BigInt`|The value to inspect|
|
|
725
|
+
|
|
726
|
+
Returns:
|
|
727
|
+
|
|
728
|
+
|type|description|
|
|
729
|
+
|----|-----------|
|
|
730
|
+
|`Int32`|The amount of leading zeros|
|
|
731
|
+
|
|
732
|
+
### Bigint.**ctz**
|
|
733
|
+
|
|
734
|
+
<details disabled>
|
|
735
|
+
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
736
|
+
No other changes yet.
|
|
737
|
+
</details>
|
|
738
|
+
|
|
739
|
+
```grain
|
|
740
|
+
ctz : BigInt -> Int64
|
|
741
|
+
```
|
|
742
|
+
|
|
743
|
+
Counts the number of trailing zero bits in the value.
|
|
744
|
+
|
|
745
|
+
Parameters:
|
|
746
|
+
|
|
747
|
+
|param|type|description|
|
|
748
|
+
|-----|----|-----------|
|
|
749
|
+
|`num`|`BigInt`|The value to inspect|
|
|
750
|
+
|
|
751
|
+
Returns:
|
|
752
|
+
|
|
753
|
+
|type|description|
|
|
754
|
+
|----|-----------|
|
|
755
|
+
|`Int64`|The amount of trailing zeros|
|
|
756
|
+
|
|
757
|
+
### Bigint.**popcnt**
|
|
758
|
+
|
|
759
|
+
<details disabled>
|
|
760
|
+
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
761
|
+
No other changes yet.
|
|
762
|
+
</details>
|
|
763
|
+
|
|
764
|
+
```grain
|
|
765
|
+
popcnt : BigInt -> Option<Int64>
|
|
766
|
+
```
|
|
767
|
+
|
|
768
|
+
Counts the number of bits set to `1` in the value, also known as a population count.
|
|
769
|
+
Will return the `None` if given a negative integer
|
|
770
|
+
|
|
771
|
+
Parameters:
|
|
772
|
+
|
|
773
|
+
|param|type|description|
|
|
774
|
+
|-----|----|-----------|
|
|
775
|
+
|`num`|`BigInt`|The value to inspect|
|
|
776
|
+
|
|
777
|
+
Returns:
|
|
778
|
+
|
|
779
|
+
|type|description|
|
|
780
|
+
|----|-----------|
|
|
781
|
+
|`Option<Int64>`|The amount of 1-bits in its operand|
|
|
782
|
+
|
|
783
|
+
## Other
|
|
784
|
+
|
|
785
|
+
Other functions on BigInts.
|
|
786
|
+
|
|
787
|
+
### Bigint.**toString**
|
|
788
|
+
|
|
789
|
+
<details disabled>
|
|
790
|
+
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
791
|
+
No other changes yet.
|
|
792
|
+
</details>
|
|
793
|
+
|
|
794
|
+
```grain
|
|
795
|
+
toString : BigInt -> String
|
|
796
|
+
```
|
|
797
|
+
|
|
798
|
+
Converts the given operand to a string.
|
|
799
|
+
|
|
800
|
+
Parameters:
|
|
801
|
+
|
|
802
|
+
|param|type|description|
|
|
803
|
+
|-----|----|-----------|
|
|
804
|
+
|`num`|`BigInt`|The operand|
|
|
805
|
+
|
|
806
|
+
Returns:
|
|
807
|
+
|
|
808
|
+
|type|description|
|
|
809
|
+
|----|-----------|
|
|
810
|
+
|`String`|The operand, as a string|
|
|
811
|
+
|