@grain/stdlib 0.6.5 → 0.7.0
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 +64 -0
- package/LICENSE +1 -1
- package/README.md +2 -2
- package/array.gr +55 -7
- package/array.md +123 -77
- package/bigint.md +30 -30
- package/buffer.gr +20 -53
- package/buffer.md +47 -47
- package/bytes.gr +111 -35
- package/bytes.md +111 -32
- package/char.gr +201 -99
- package/char.md +361 -34
- package/exception.gr +11 -11
- package/exception.md +26 -1
- package/float32.gr +327 -3
- package/float32.md +606 -19
- package/float64.gr +320 -3
- package/float64.md +606 -19
- package/fs.gr +1082 -0
- package/fs.md +630 -0
- package/hash.gr +142 -88
- package/hash.md +102 -14
- package/int16.md +23 -23
- package/int32.gr +25 -4
- package/int32.md +65 -30
- package/int64.gr +26 -1
- package/int64.md +65 -30
- package/int8.md +23 -23
- package/json.gr +366 -51
- package/json.md +418 -2
- package/list.gr +387 -49
- package/list.md +492 -69
- package/map.gr +20 -12
- package/map.md +44 -38
- package/marshal.gr +41 -40
- package/marshal.md +2 -2
- package/number.gr +159 -30
- package/number.md +215 -38
- package/option.md +21 -21
- package/package.json +5 -3
- package/path.gr +48 -0
- package/path.md +103 -12
- package/pervasives.gr +2 -2
- package/pervasives.md +37 -37
- package/priorityqueue.gr +7 -7
- package/priorityqueue.md +19 -19
- package/queue.gr +183 -29
- package/queue.md +296 -40
- package/random.md +6 -6
- package/range.gr +4 -4
- package/range.md +6 -6
- package/rational.md +16 -16
- package/regex.gr +52 -51
- package/regex.md +11 -11
- package/result.md +16 -16
- package/runtime/atof/common.md +39 -39
- package/runtime/atof/decimal.gr +6 -6
- package/runtime/atof/decimal.md +8 -8
- 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 +1 -1
- package/runtime/dataStructures.md +33 -33
- package/runtime/debugPrint.gr +4 -1
- package/runtime/debugPrint.md +9 -9
- package/runtime/equal.gr +99 -77
- package/runtime/equal.md +1 -1
- 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 +4 -4
- 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 +79 -73
- package/runtime/string.gr +37 -105
- package/runtime/string.md +3 -9
- package/runtime/unsafe/constants.md +24 -24
- package/runtime/unsafe/conv.md +13 -13
- 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 +138 -138
- package/set.gr +18 -11
- package/set.md +42 -36
- package/stack.gr +171 -2
- package/stack.md +297 -15
- package/string.gr +352 -557
- package/string.md +77 -34
- package/uint16.gr +81 -0
- package/uint16.md +183 -22
- package/uint32.gr +25 -4
- package/uint32.md +63 -28
- package/uint64.gr +25 -5
- package/uint64.md +63 -28
- package/uint8.gr +81 -0
- package/uint8.md +183 -22
- package/uri.gr +57 -53
- package/uri.md +11 -12
- package/wasi/file.gr +67 -59
- package/wasi/file.md +39 -39
- package/wasi/process.md +5 -5
- package/wasi/random.md +3 -3
- package/wasi/time.md +4 -4
- package/runtime/utils/printing.gr +0 -60
- package/runtime/utils/printing.md +0 -26
package/uint32.md
CHANGED
|
@@ -25,7 +25,7 @@ No other changes yet.
|
|
|
25
25
|
</details>
|
|
26
26
|
|
|
27
27
|
```grain
|
|
28
|
-
fromNumber
|
|
28
|
+
fromNumber: (number: Number) => Uint32
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
Converts a Number to a Uint32.
|
|
@@ -50,7 +50,7 @@ No other changes yet.
|
|
|
50
50
|
</details>
|
|
51
51
|
|
|
52
52
|
```grain
|
|
53
|
-
toNumber
|
|
53
|
+
toNumber: (value: Uint32) => Number
|
|
54
54
|
```
|
|
55
55
|
|
|
56
56
|
Converts a Uint32 to a Number.
|
|
@@ -75,7 +75,7 @@ No other changes yet.
|
|
|
75
75
|
</details>
|
|
76
76
|
|
|
77
77
|
```grain
|
|
78
|
-
fromInt32
|
|
78
|
+
fromInt32: (number: Int32) => Uint32
|
|
79
79
|
```
|
|
80
80
|
|
|
81
81
|
Converts an Int32 to a Uint32.
|
|
@@ -92,6 +92,41 @@ Returns:
|
|
|
92
92
|
|----|-----------|
|
|
93
93
|
|`Uint32`|The Int32 represented as a Uint32|
|
|
94
94
|
|
|
95
|
+
### Uint32.**reinterpretFloat32**
|
|
96
|
+
|
|
97
|
+
<details disabled>
|
|
98
|
+
<summary tabindex="-1">Added in <code>0.7.0</code></summary>
|
|
99
|
+
No other changes yet.
|
|
100
|
+
</details>
|
|
101
|
+
|
|
102
|
+
```grain
|
|
103
|
+
reinterpretFloat32: (value: Float32) => Uint32
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Interprets a Float32 as an Uint32.
|
|
107
|
+
|
|
108
|
+
Parameters:
|
|
109
|
+
|
|
110
|
+
|param|type|description|
|
|
111
|
+
|-----|----|-----------|
|
|
112
|
+
|`value`|`Float32`|The value to convert|
|
|
113
|
+
|
|
114
|
+
Returns:
|
|
115
|
+
|
|
116
|
+
|type|description|
|
|
117
|
+
|----|-----------|
|
|
118
|
+
|`Uint32`|The Float32 interpreted as an Uint32|
|
|
119
|
+
|
|
120
|
+
Examples:
|
|
121
|
+
|
|
122
|
+
```grain
|
|
123
|
+
assert Uint32.reinterpretFloat32(1.0f) == 1065353216ul
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
```grain
|
|
127
|
+
assert Uint32.reinterpretFloat32(-1.0f) == 3212836864ul
|
|
128
|
+
```
|
|
129
|
+
|
|
95
130
|
### Uint32.**incr**
|
|
96
131
|
|
|
97
132
|
<details disabled>
|
|
@@ -100,7 +135,7 @@ No other changes yet.
|
|
|
100
135
|
</details>
|
|
101
136
|
|
|
102
137
|
```grain
|
|
103
|
-
incr
|
|
138
|
+
incr: (value: Uint32) => Uint32
|
|
104
139
|
```
|
|
105
140
|
|
|
106
141
|
Increments the value by one.
|
|
@@ -125,7 +160,7 @@ No other changes yet.
|
|
|
125
160
|
</details>
|
|
126
161
|
|
|
127
162
|
```grain
|
|
128
|
-
decr
|
|
163
|
+
decr: (value: Uint32) => Uint32
|
|
129
164
|
```
|
|
130
165
|
|
|
131
166
|
Decrements the value by one.
|
|
@@ -150,7 +185,7 @@ No other changes yet.
|
|
|
150
185
|
</details>
|
|
151
186
|
|
|
152
187
|
```grain
|
|
153
|
-
(+)
|
|
188
|
+
(+): (x: Uint32, y: Uint32) => Uint32
|
|
154
189
|
```
|
|
155
190
|
|
|
156
191
|
Computes the sum of its operands.
|
|
@@ -176,7 +211,7 @@ No other changes yet.
|
|
|
176
211
|
</details>
|
|
177
212
|
|
|
178
213
|
```grain
|
|
179
|
-
(-)
|
|
214
|
+
(-): (x: Uint32, y: Uint32) => Uint32
|
|
180
215
|
```
|
|
181
216
|
|
|
182
217
|
Computes the difference of its operands.
|
|
@@ -202,7 +237,7 @@ No other changes yet.
|
|
|
202
237
|
</details>
|
|
203
238
|
|
|
204
239
|
```grain
|
|
205
|
-
(*)
|
|
240
|
+
(*): (x: Uint32, y: Uint32) => Uint32
|
|
206
241
|
```
|
|
207
242
|
|
|
208
243
|
Computes the product of its operands.
|
|
@@ -228,7 +263,7 @@ No other changes yet.
|
|
|
228
263
|
</details>
|
|
229
264
|
|
|
230
265
|
```grain
|
|
231
|
-
(/)
|
|
266
|
+
(/): (x: Uint32, y: Uint32) => Uint32
|
|
232
267
|
```
|
|
233
268
|
|
|
234
269
|
Computes the quotient of its operands.
|
|
@@ -254,7 +289,7 @@ No other changes yet.
|
|
|
254
289
|
</details>
|
|
255
290
|
|
|
256
291
|
```grain
|
|
257
|
-
rem
|
|
292
|
+
rem: (x: Uint32, y: Uint32) => Uint32
|
|
258
293
|
```
|
|
259
294
|
|
|
260
295
|
Computes the remainder of the division of its operands.
|
|
@@ -280,7 +315,7 @@ No other changes yet.
|
|
|
280
315
|
</details>
|
|
281
316
|
|
|
282
317
|
```grain
|
|
283
|
-
rotl
|
|
318
|
+
rotl: (value: Uint32, amount: Uint32) => Uint32
|
|
284
319
|
```
|
|
285
320
|
|
|
286
321
|
Rotates the bits of the value left by the given number of bits.
|
|
@@ -306,7 +341,7 @@ No other changes yet.
|
|
|
306
341
|
</details>
|
|
307
342
|
|
|
308
343
|
```grain
|
|
309
|
-
rotr
|
|
344
|
+
rotr: (value: Uint32, amount: Uint32) => Uint32
|
|
310
345
|
```
|
|
311
346
|
|
|
312
347
|
Rotates the bits of the value right by the given number of bits.
|
|
@@ -332,7 +367,7 @@ No other changes yet.
|
|
|
332
367
|
</details>
|
|
333
368
|
|
|
334
369
|
```grain
|
|
335
|
-
(<<)
|
|
370
|
+
(<<): (value: Uint32, amount: Uint32) => Uint32
|
|
336
371
|
```
|
|
337
372
|
|
|
338
373
|
Shifts the bits of the value left by the given number of bits.
|
|
@@ -358,7 +393,7 @@ No other changes yet.
|
|
|
358
393
|
</details>
|
|
359
394
|
|
|
360
395
|
```grain
|
|
361
|
-
(>>>)
|
|
396
|
+
(>>>): (value: Uint32, amount: Uint32) => Uint32
|
|
362
397
|
```
|
|
363
398
|
|
|
364
399
|
Shifts the bits of the value right by the given number of bits.
|
|
@@ -384,7 +419,7 @@ No other changes yet.
|
|
|
384
419
|
</details>
|
|
385
420
|
|
|
386
421
|
```grain
|
|
387
|
-
(==)
|
|
422
|
+
(==): (x: Uint32, y: Uint32) => Bool
|
|
388
423
|
```
|
|
389
424
|
|
|
390
425
|
Checks if the first value is equal to the second value.
|
|
@@ -410,7 +445,7 @@ No other changes yet.
|
|
|
410
445
|
</details>
|
|
411
446
|
|
|
412
447
|
```grain
|
|
413
|
-
(!=)
|
|
448
|
+
(!=): (x: Uint32, y: Uint32) => Bool
|
|
414
449
|
```
|
|
415
450
|
|
|
416
451
|
Checks if the first value is not equal to the second value.
|
|
@@ -436,7 +471,7 @@ No other changes yet.
|
|
|
436
471
|
</details>
|
|
437
472
|
|
|
438
473
|
```grain
|
|
439
|
-
eqz
|
|
474
|
+
eqz: (value: Uint32) => Bool
|
|
440
475
|
```
|
|
441
476
|
|
|
442
477
|
Checks if the given value is equal to zero.
|
|
@@ -461,7 +496,7 @@ No other changes yet.
|
|
|
461
496
|
</details>
|
|
462
497
|
|
|
463
498
|
```grain
|
|
464
|
-
(<)
|
|
499
|
+
(<): (x: Uint32, y: Uint32) => Bool
|
|
465
500
|
```
|
|
466
501
|
|
|
467
502
|
Checks if the first value is less than the second value.
|
|
@@ -487,7 +522,7 @@ No other changes yet.
|
|
|
487
522
|
</details>
|
|
488
523
|
|
|
489
524
|
```grain
|
|
490
|
-
(>)
|
|
525
|
+
(>): (x: Uint32, y: Uint32) => Bool
|
|
491
526
|
```
|
|
492
527
|
|
|
493
528
|
Checks if the first value is greater than the second value.
|
|
@@ -513,7 +548,7 @@ No other changes yet.
|
|
|
513
548
|
</details>
|
|
514
549
|
|
|
515
550
|
```grain
|
|
516
|
-
(<=)
|
|
551
|
+
(<=): (x: Uint32, y: Uint32) => Bool
|
|
517
552
|
```
|
|
518
553
|
|
|
519
554
|
Checks if the first value is less than or equal to the second value.
|
|
@@ -539,7 +574,7 @@ No other changes yet.
|
|
|
539
574
|
</details>
|
|
540
575
|
|
|
541
576
|
```grain
|
|
542
|
-
(>=)
|
|
577
|
+
(>=): (x: Uint32, y: Uint32) => Bool
|
|
543
578
|
```
|
|
544
579
|
|
|
545
580
|
Checks if the first value is greater than or equal to the second value.
|
|
@@ -565,7 +600,7 @@ No other changes yet.
|
|
|
565
600
|
</details>
|
|
566
601
|
|
|
567
602
|
```grain
|
|
568
|
-
lnot
|
|
603
|
+
lnot: (value: Uint32) => Uint32
|
|
569
604
|
```
|
|
570
605
|
|
|
571
606
|
Computes the bitwise NOT of the given value.
|
|
@@ -590,7 +625,7 @@ No other changes yet.
|
|
|
590
625
|
</details>
|
|
591
626
|
|
|
592
627
|
```grain
|
|
593
|
-
(&)
|
|
628
|
+
(&): (x: Uint32, y: Uint32) => Uint32
|
|
594
629
|
```
|
|
595
630
|
|
|
596
631
|
Computes the bitwise AND (`&`) on the given operands.
|
|
@@ -616,7 +651,7 @@ No other changes yet.
|
|
|
616
651
|
</details>
|
|
617
652
|
|
|
618
653
|
```grain
|
|
619
|
-
(|)
|
|
654
|
+
(|): (x: Uint32, y: Uint32) => Uint32
|
|
620
655
|
```
|
|
621
656
|
|
|
622
657
|
Computes the bitwise OR (`|`) on the given operands.
|
|
@@ -642,7 +677,7 @@ No other changes yet.
|
|
|
642
677
|
</details>
|
|
643
678
|
|
|
644
679
|
```grain
|
|
645
|
-
(^)
|
|
680
|
+
(^): (x: Uint32, y: Uint32) => Uint32
|
|
646
681
|
```
|
|
647
682
|
|
|
648
683
|
Computes the bitwise XOR (`^`) on the given operands.
|
|
@@ -668,7 +703,7 @@ No other changes yet.
|
|
|
668
703
|
</details>
|
|
669
704
|
|
|
670
705
|
```grain
|
|
671
|
-
clz
|
|
706
|
+
clz: (value: Uint32) => Uint32
|
|
672
707
|
```
|
|
673
708
|
|
|
674
709
|
Counts the number of leading zero bits in the value.
|
|
@@ -693,7 +728,7 @@ No other changes yet.
|
|
|
693
728
|
</details>
|
|
694
729
|
|
|
695
730
|
```grain
|
|
696
|
-
ctz
|
|
731
|
+
ctz: (value: Uint32) => Uint32
|
|
697
732
|
```
|
|
698
733
|
|
|
699
734
|
Counts the number of trailing zero bits in the value.
|
|
@@ -718,7 +753,7 @@ No other changes yet.
|
|
|
718
753
|
</details>
|
|
719
754
|
|
|
720
755
|
```grain
|
|
721
|
-
popcnt
|
|
756
|
+
popcnt: (value: Uint32) => Uint32
|
|
722
757
|
```
|
|
723
758
|
|
|
724
759
|
Counts the number of bits set to `1` in the value, also known as a population count.
|
package/uint64.gr
CHANGED
|
@@ -6,6 +6,12 @@
|
|
|
6
6
|
*/
|
|
7
7
|
module Uint64
|
|
8
8
|
|
|
9
|
+
from "runtime/unsafe/offsets" include Offsets
|
|
10
|
+
use Offsets.{
|
|
11
|
+
_UINT64_VALUE_OFFSET as _VALUE_OFFSET,
|
|
12
|
+
_INT64_VALUE_OFFSET,
|
|
13
|
+
_FLOAT64_VALUE_OFFSET,
|
|
14
|
+
}
|
|
9
15
|
from "runtime/unsafe/wasmi32" include WasmI32
|
|
10
16
|
from "runtime/unsafe/wasmi64" include WasmI64
|
|
11
17
|
use WasmI64.{ (==), (!=), (&), (|), (^), (+), (-), (*), (<<), (>>>) }
|
|
@@ -16,10 +22,6 @@ use Numbers.{ reducedUnsignedInteger, coerceNumberToUnsignedWasmI64 }
|
|
|
16
22
|
from "runtime/dataStructures" include DataStructures
|
|
17
23
|
use DataStructures.{ newUint64 }
|
|
18
24
|
|
|
19
|
-
// First 8 bytes of 64-bit unsigned int are heap tag and 32 bits of padding
|
|
20
|
-
@unsafe
|
|
21
|
-
let _VALUE_OFFSET = 8n
|
|
22
|
-
|
|
23
25
|
/**
|
|
24
26
|
* Converts a Number to a Uint64.
|
|
25
27
|
*
|
|
@@ -61,7 +63,25 @@ provide let toNumber = (value: Uint64) => {
|
|
|
61
63
|
*/
|
|
62
64
|
@unsafe
|
|
63
65
|
provide let fromInt64 = (number: Int64) => {
|
|
64
|
-
let x = WasmI64.load(WasmI32.fromGrain(number),
|
|
66
|
+
let x = WasmI64.load(WasmI32.fromGrain(number), _INT64_VALUE_OFFSET)
|
|
67
|
+
let result = newUint64(x)
|
|
68
|
+
WasmI32.toGrain(result): Uint64
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Interprets a Float64 as an Uint64.
|
|
73
|
+
*
|
|
74
|
+
* @param value: The value to convert
|
|
75
|
+
* @returns The Float64 interpreted as an Uint64
|
|
76
|
+
*
|
|
77
|
+
* @example assert Uint64.reinterpretFloat64(1.0d) == 4607182418800017408uL
|
|
78
|
+
* @example assert Uint64.reinterpretFloat64(-1.0d) == 13830554455654793216uL
|
|
79
|
+
*
|
|
80
|
+
* @since v0.7.0
|
|
81
|
+
*/
|
|
82
|
+
@unsafe
|
|
83
|
+
provide let reinterpretFloat64 = (value: Float64) => {
|
|
84
|
+
let x = WasmI64.load(WasmI32.fromGrain(value), _FLOAT64_VALUE_OFFSET)
|
|
65
85
|
let result = newUint64(x)
|
|
66
86
|
WasmI32.toGrain(result): Uint64
|
|
67
87
|
}
|
package/uint64.md
CHANGED
|
@@ -25,7 +25,7 @@ No other changes yet.
|
|
|
25
25
|
</details>
|
|
26
26
|
|
|
27
27
|
```grain
|
|
28
|
-
fromNumber
|
|
28
|
+
fromNumber: (number: Number) => Uint64
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
Converts a Number to a Uint64.
|
|
@@ -50,7 +50,7 @@ No other changes yet.
|
|
|
50
50
|
</details>
|
|
51
51
|
|
|
52
52
|
```grain
|
|
53
|
-
toNumber
|
|
53
|
+
toNumber: (value: Uint64) => Number
|
|
54
54
|
```
|
|
55
55
|
|
|
56
56
|
Converts a Uint64 to a Number.
|
|
@@ -75,7 +75,7 @@ No other changes yet.
|
|
|
75
75
|
</details>
|
|
76
76
|
|
|
77
77
|
```grain
|
|
78
|
-
fromInt64
|
|
78
|
+
fromInt64: (number: Int64) => Uint64
|
|
79
79
|
```
|
|
80
80
|
|
|
81
81
|
Converts an Int64 to a Uint64.
|
|
@@ -92,6 +92,41 @@ Returns:
|
|
|
92
92
|
|----|-----------|
|
|
93
93
|
|`Uint64`|The Int64 represented as a Uint64|
|
|
94
94
|
|
|
95
|
+
### Uint64.**reinterpretFloat64**
|
|
96
|
+
|
|
97
|
+
<details disabled>
|
|
98
|
+
<summary tabindex="-1">Added in <code>0.7.0</code></summary>
|
|
99
|
+
No other changes yet.
|
|
100
|
+
</details>
|
|
101
|
+
|
|
102
|
+
```grain
|
|
103
|
+
reinterpretFloat64: (value: Float64) => Uint64
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Interprets a Float64 as an Uint64.
|
|
107
|
+
|
|
108
|
+
Parameters:
|
|
109
|
+
|
|
110
|
+
|param|type|description|
|
|
111
|
+
|-----|----|-----------|
|
|
112
|
+
|`value`|`Float64`|The value to convert|
|
|
113
|
+
|
|
114
|
+
Returns:
|
|
115
|
+
|
|
116
|
+
|type|description|
|
|
117
|
+
|----|-----------|
|
|
118
|
+
|`Uint64`|The Float64 interpreted as an Uint64|
|
|
119
|
+
|
|
120
|
+
Examples:
|
|
121
|
+
|
|
122
|
+
```grain
|
|
123
|
+
assert Uint64.reinterpretFloat64(1.0d) == 4607182418800017408uL
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
```grain
|
|
127
|
+
assert Uint64.reinterpretFloat64(-1.0d) == 13830554455654793216uL
|
|
128
|
+
```
|
|
129
|
+
|
|
95
130
|
### Uint64.**incr**
|
|
96
131
|
|
|
97
132
|
<details disabled>
|
|
@@ -100,7 +135,7 @@ No other changes yet.
|
|
|
100
135
|
</details>
|
|
101
136
|
|
|
102
137
|
```grain
|
|
103
|
-
incr
|
|
138
|
+
incr: (value: Uint64) => Uint64
|
|
104
139
|
```
|
|
105
140
|
|
|
106
141
|
Increments the value by one.
|
|
@@ -125,7 +160,7 @@ No other changes yet.
|
|
|
125
160
|
</details>
|
|
126
161
|
|
|
127
162
|
```grain
|
|
128
|
-
decr
|
|
163
|
+
decr: (value: Uint64) => Uint64
|
|
129
164
|
```
|
|
130
165
|
|
|
131
166
|
Decrements the value by one.
|
|
@@ -150,7 +185,7 @@ No other changes yet.
|
|
|
150
185
|
</details>
|
|
151
186
|
|
|
152
187
|
```grain
|
|
153
|
-
(+)
|
|
188
|
+
(+): (x: Uint64, y: Uint64) => Uint64
|
|
154
189
|
```
|
|
155
190
|
|
|
156
191
|
Computes the sum of its operands.
|
|
@@ -176,7 +211,7 @@ No other changes yet.
|
|
|
176
211
|
</details>
|
|
177
212
|
|
|
178
213
|
```grain
|
|
179
|
-
(-)
|
|
214
|
+
(-): (x: Uint64, y: Uint64) => Uint64
|
|
180
215
|
```
|
|
181
216
|
|
|
182
217
|
Computes the difference of its operands.
|
|
@@ -202,7 +237,7 @@ No other changes yet.
|
|
|
202
237
|
</details>
|
|
203
238
|
|
|
204
239
|
```grain
|
|
205
|
-
(*)
|
|
240
|
+
(*): (x: Uint64, y: Uint64) => Uint64
|
|
206
241
|
```
|
|
207
242
|
|
|
208
243
|
Computes the product of its operands.
|
|
@@ -228,7 +263,7 @@ No other changes yet.
|
|
|
228
263
|
</details>
|
|
229
264
|
|
|
230
265
|
```grain
|
|
231
|
-
(/)
|
|
266
|
+
(/): (x: Uint64, y: Uint64) => Uint64
|
|
232
267
|
```
|
|
233
268
|
|
|
234
269
|
Computes the quotient of its operands.
|
|
@@ -254,7 +289,7 @@ No other changes yet.
|
|
|
254
289
|
</details>
|
|
255
290
|
|
|
256
291
|
```grain
|
|
257
|
-
rem
|
|
292
|
+
rem: (x: Uint64, y: Uint64) => Uint64
|
|
258
293
|
```
|
|
259
294
|
|
|
260
295
|
Computes the remainder of the division of its operands.
|
|
@@ -280,7 +315,7 @@ No other changes yet.
|
|
|
280
315
|
</details>
|
|
281
316
|
|
|
282
317
|
```grain
|
|
283
|
-
rotl
|
|
318
|
+
rotl: (value: Uint64, amount: Uint64) => Uint64
|
|
284
319
|
```
|
|
285
320
|
|
|
286
321
|
Rotates the bits of the value left by the given number of bits.
|
|
@@ -306,7 +341,7 @@ No other changes yet.
|
|
|
306
341
|
</details>
|
|
307
342
|
|
|
308
343
|
```grain
|
|
309
|
-
rotr
|
|
344
|
+
rotr: (value: Uint64, amount: Uint64) => Uint64
|
|
310
345
|
```
|
|
311
346
|
|
|
312
347
|
Rotates the bits of the value right by the given number of bits.
|
|
@@ -332,7 +367,7 @@ No other changes yet.
|
|
|
332
367
|
</details>
|
|
333
368
|
|
|
334
369
|
```grain
|
|
335
|
-
(<<)
|
|
370
|
+
(<<): (value: Uint64, amount: Uint64) => Uint64
|
|
336
371
|
```
|
|
337
372
|
|
|
338
373
|
Shifts the bits of the value left by the given number of bits.
|
|
@@ -358,7 +393,7 @@ No other changes yet.
|
|
|
358
393
|
</details>
|
|
359
394
|
|
|
360
395
|
```grain
|
|
361
|
-
(>>>)
|
|
396
|
+
(>>>): (value: Uint64, amount: Uint64) => Uint64
|
|
362
397
|
```
|
|
363
398
|
|
|
364
399
|
Shifts the bits of the value right by the given number of bits.
|
|
@@ -384,7 +419,7 @@ No other changes yet.
|
|
|
384
419
|
</details>
|
|
385
420
|
|
|
386
421
|
```grain
|
|
387
|
-
(==)
|
|
422
|
+
(==): (x: Uint64, y: Uint64) => Bool
|
|
388
423
|
```
|
|
389
424
|
|
|
390
425
|
Checks if the first value is equal to the second value.
|
|
@@ -410,7 +445,7 @@ No other changes yet.
|
|
|
410
445
|
</details>
|
|
411
446
|
|
|
412
447
|
```grain
|
|
413
|
-
(!=)
|
|
448
|
+
(!=): (x: Uint64, y: Uint64) => Bool
|
|
414
449
|
```
|
|
415
450
|
|
|
416
451
|
Checks if the first value is not equal to the second value.
|
|
@@ -436,7 +471,7 @@ No other changes yet.
|
|
|
436
471
|
</details>
|
|
437
472
|
|
|
438
473
|
```grain
|
|
439
|
-
eqz
|
|
474
|
+
eqz: (value: Uint64) => Bool
|
|
440
475
|
```
|
|
441
476
|
|
|
442
477
|
Checks if the given value is equal to zero.
|
|
@@ -461,7 +496,7 @@ No other changes yet.
|
|
|
461
496
|
</details>
|
|
462
497
|
|
|
463
498
|
```grain
|
|
464
|
-
(<)
|
|
499
|
+
(<): (x: Uint64, y: Uint64) => Bool
|
|
465
500
|
```
|
|
466
501
|
|
|
467
502
|
Checks if the first value is less than the second value.
|
|
@@ -487,7 +522,7 @@ No other changes yet.
|
|
|
487
522
|
</details>
|
|
488
523
|
|
|
489
524
|
```grain
|
|
490
|
-
(>)
|
|
525
|
+
(>): (x: Uint64, y: Uint64) => Bool
|
|
491
526
|
```
|
|
492
527
|
|
|
493
528
|
Checks if the first value is greater than the second value.
|
|
@@ -513,7 +548,7 @@ No other changes yet.
|
|
|
513
548
|
</details>
|
|
514
549
|
|
|
515
550
|
```grain
|
|
516
|
-
(<=)
|
|
551
|
+
(<=): (x: Uint64, y: Uint64) => Bool
|
|
517
552
|
```
|
|
518
553
|
|
|
519
554
|
Checks if the first value is less than or equal to the second value.
|
|
@@ -539,7 +574,7 @@ No other changes yet.
|
|
|
539
574
|
</details>
|
|
540
575
|
|
|
541
576
|
```grain
|
|
542
|
-
(>=)
|
|
577
|
+
(>=): (x: Uint64, y: Uint64) => Bool
|
|
543
578
|
```
|
|
544
579
|
|
|
545
580
|
Checks if the first value is greater than or equal to the second value.
|
|
@@ -565,7 +600,7 @@ No other changes yet.
|
|
|
565
600
|
</details>
|
|
566
601
|
|
|
567
602
|
```grain
|
|
568
|
-
lnot
|
|
603
|
+
lnot: (value: Uint64) => Uint64
|
|
569
604
|
```
|
|
570
605
|
|
|
571
606
|
Computes the bitwise NOT of the given value.
|
|
@@ -590,7 +625,7 @@ No other changes yet.
|
|
|
590
625
|
</details>
|
|
591
626
|
|
|
592
627
|
```grain
|
|
593
|
-
(&)
|
|
628
|
+
(&): (x: Uint64, y: Uint64) => Uint64
|
|
594
629
|
```
|
|
595
630
|
|
|
596
631
|
Computes the bitwise AND (`&`) on the given operands.
|
|
@@ -616,7 +651,7 @@ No other changes yet.
|
|
|
616
651
|
</details>
|
|
617
652
|
|
|
618
653
|
```grain
|
|
619
|
-
(|)
|
|
654
|
+
(|): (x: Uint64, y: Uint64) => Uint64
|
|
620
655
|
```
|
|
621
656
|
|
|
622
657
|
Computes the bitwise OR (`|`) on the given operands.
|
|
@@ -642,7 +677,7 @@ No other changes yet.
|
|
|
642
677
|
</details>
|
|
643
678
|
|
|
644
679
|
```grain
|
|
645
|
-
(^)
|
|
680
|
+
(^): (x: Uint64, y: Uint64) => Uint64
|
|
646
681
|
```
|
|
647
682
|
|
|
648
683
|
Computes the bitwise XOR (`^`) on the given operands.
|
|
@@ -668,7 +703,7 @@ No other changes yet.
|
|
|
668
703
|
</details>
|
|
669
704
|
|
|
670
705
|
```grain
|
|
671
|
-
clz
|
|
706
|
+
clz: (value: Uint64) => Uint64
|
|
672
707
|
```
|
|
673
708
|
|
|
674
709
|
Counts the number of leading zero bits in the value.
|
|
@@ -693,7 +728,7 @@ No other changes yet.
|
|
|
693
728
|
</details>
|
|
694
729
|
|
|
695
730
|
```grain
|
|
696
|
-
ctz
|
|
731
|
+
ctz: (value: Uint64) => Uint64
|
|
697
732
|
```
|
|
698
733
|
|
|
699
734
|
Counts the number of trailing zero bits in the value.
|
|
@@ -718,7 +753,7 @@ No other changes yet.
|
|
|
718
753
|
</details>
|
|
719
754
|
|
|
720
755
|
```grain
|
|
721
|
-
popcnt
|
|
756
|
+
popcnt: (value: Uint64) => Uint64
|
|
722
757
|
```
|
|
723
758
|
|
|
724
759
|
Counts the number of bits set to `1` in the value, also known as a population count.
|