@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.
Files changed (139) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/LICENSE +1 -1
  3. package/README.md +2 -2
  4. package/array.gr +55 -7
  5. package/array.md +123 -77
  6. package/bigint.md +30 -30
  7. package/buffer.gr +20 -53
  8. package/buffer.md +47 -47
  9. package/bytes.gr +111 -35
  10. package/bytes.md +111 -32
  11. package/char.gr +201 -99
  12. package/char.md +361 -34
  13. package/exception.gr +11 -11
  14. package/exception.md +26 -1
  15. package/float32.gr +327 -3
  16. package/float32.md +606 -19
  17. package/float64.gr +320 -3
  18. package/float64.md +606 -19
  19. package/fs.gr +1082 -0
  20. package/fs.md +630 -0
  21. package/hash.gr +142 -88
  22. package/hash.md +102 -14
  23. package/int16.md +23 -23
  24. package/int32.gr +25 -4
  25. package/int32.md +65 -30
  26. package/int64.gr +26 -1
  27. package/int64.md +65 -30
  28. package/int8.md +23 -23
  29. package/json.gr +366 -51
  30. package/json.md +418 -2
  31. package/list.gr +387 -49
  32. package/list.md +492 -69
  33. package/map.gr +20 -12
  34. package/map.md +44 -38
  35. package/marshal.gr +41 -40
  36. package/marshal.md +2 -2
  37. package/number.gr +159 -30
  38. package/number.md +215 -38
  39. package/option.md +21 -21
  40. package/package.json +5 -3
  41. package/path.gr +48 -0
  42. package/path.md +103 -12
  43. package/pervasives.gr +2 -2
  44. package/pervasives.md +37 -37
  45. package/priorityqueue.gr +7 -7
  46. package/priorityqueue.md +19 -19
  47. package/queue.gr +183 -29
  48. package/queue.md +296 -40
  49. package/random.md +6 -6
  50. package/range.gr +4 -4
  51. package/range.md +6 -6
  52. package/rational.md +16 -16
  53. package/regex.gr +52 -51
  54. package/regex.md +11 -11
  55. package/result.md +16 -16
  56. package/runtime/atof/common.md +39 -39
  57. package/runtime/atof/decimal.gr +6 -6
  58. package/runtime/atof/decimal.md +8 -8
  59. package/runtime/atof/lemire.gr +5 -5
  60. package/runtime/atof/lemire.md +1 -1
  61. package/runtime/atof/parse.gr +16 -16
  62. package/runtime/atof/parse.md +2 -2
  63. package/runtime/atof/slow.md +1 -1
  64. package/runtime/atof/table.md +2 -2
  65. package/runtime/atoi/parse.gr +3 -3
  66. package/runtime/atoi/parse.md +1 -1
  67. package/runtime/bigint.gr +15 -47
  68. package/runtime/bigint.md +54 -60
  69. package/runtime/compare.gr +2 -2
  70. package/runtime/compare.md +1 -1
  71. package/runtime/dataStructures.md +33 -33
  72. package/runtime/debugPrint.gr +4 -1
  73. package/runtime/debugPrint.md +9 -9
  74. package/runtime/equal.gr +99 -77
  75. package/runtime/equal.md +1 -1
  76. package/runtime/exception.gr +62 -82
  77. package/runtime/exception.md +62 -11
  78. package/runtime/gc.gr +39 -45
  79. package/runtime/gc.md +4 -4
  80. package/runtime/malloc.gr +7 -7
  81. package/runtime/malloc.md +4 -4
  82. package/runtime/math/kernel/cos.gr +70 -0
  83. package/runtime/math/kernel/cos.md +14 -0
  84. package/runtime/math/kernel/sin.gr +65 -0
  85. package/runtime/math/kernel/sin.md +14 -0
  86. package/runtime/math/kernel/tan.gr +136 -0
  87. package/runtime/math/kernel/tan.md +14 -0
  88. package/runtime/math/rempio2.gr +244 -0
  89. package/runtime/math/rempio2.md +14 -0
  90. package/runtime/math/trig.gr +130 -0
  91. package/runtime/math/trig.md +28 -0
  92. package/runtime/math/umuldi.gr +26 -0
  93. package/runtime/math/umuldi.md +14 -0
  94. package/runtime/numberUtils.gr +29 -29
  95. package/runtime/numberUtils.md +12 -12
  96. package/runtime/numbers.gr +373 -381
  97. package/runtime/numbers.md +79 -73
  98. package/runtime/string.gr +37 -105
  99. package/runtime/string.md +3 -9
  100. package/runtime/unsafe/constants.md +24 -24
  101. package/runtime/unsafe/conv.md +13 -13
  102. package/runtime/unsafe/memory.gr +24 -20
  103. package/runtime/unsafe/memory.md +27 -7
  104. package/runtime/unsafe/offsets.gr +36 -0
  105. package/runtime/unsafe/offsets.md +88 -0
  106. package/runtime/unsafe/panic.gr +28 -0
  107. package/runtime/unsafe/panic.md +14 -0
  108. package/runtime/unsafe/tags.md +32 -32
  109. package/runtime/unsafe/wasmf32.md +28 -28
  110. package/runtime/unsafe/wasmf64.md +28 -28
  111. package/runtime/unsafe/wasmi32.md +47 -47
  112. package/runtime/unsafe/wasmi64.md +50 -50
  113. package/runtime/utf8.gr +189 -0
  114. package/runtime/utf8.md +117 -0
  115. package/runtime/wasi.gr +4 -2
  116. package/runtime/wasi.md +138 -138
  117. package/set.gr +18 -11
  118. package/set.md +42 -36
  119. package/stack.gr +171 -2
  120. package/stack.md +297 -15
  121. package/string.gr +352 -557
  122. package/string.md +77 -34
  123. package/uint16.gr +81 -0
  124. package/uint16.md +183 -22
  125. package/uint32.gr +25 -4
  126. package/uint32.md +63 -28
  127. package/uint64.gr +25 -5
  128. package/uint64.md +63 -28
  129. package/uint8.gr +81 -0
  130. package/uint8.md +183 -22
  131. package/uri.gr +57 -53
  132. package/uri.md +11 -12
  133. package/wasi/file.gr +67 -59
  134. package/wasi/file.md +39 -39
  135. package/wasi/process.md +5 -5
  136. package/wasi/random.md +3 -3
  137. package/wasi/time.md +4 -4
  138. package/runtime/utils/printing.gr +0 -60
  139. package/runtime/utils/printing.md +0 -26
package/uint16.md CHANGED
@@ -13,6 +13,14 @@ No other changes yet.
13
13
  from "uint16" include Uint16
14
14
  ```
15
15
 
16
+ ```grain
17
+ 1uS
18
+ ```
19
+
20
+ ```grain
21
+ 10uS
22
+ ```
23
+
16
24
  ## Values
17
25
 
18
26
  Functions and constants included in the Uint16 module.
@@ -25,7 +33,7 @@ No other changes yet.
25
33
  </details>
26
34
 
27
35
  ```grain
28
- fromNumber : (number: Number) => Uint16
36
+ fromNumber: (number: Number) => Uint16
29
37
  ```
30
38
 
31
39
  Converts a Number to a Uint16.
@@ -50,7 +58,7 @@ No other changes yet.
50
58
  </details>
51
59
 
52
60
  ```grain
53
- toNumber : (value: Uint16) => Number
61
+ toNumber: (value: Uint16) => Number
54
62
  ```
55
63
 
56
64
  Converts a Uint16 to a Number.
@@ -75,7 +83,7 @@ No other changes yet.
75
83
  </details>
76
84
 
77
85
  ```grain
78
- fromInt16 : (number: Int16) => Uint16
86
+ fromInt16: (number: Int16) => Uint16
79
87
  ```
80
88
 
81
89
  Converts an Int16 to a Uint16.
@@ -92,6 +100,16 @@ Returns:
92
100
  |----|-----------|
93
101
  |`Uint16`|The Int16 represented as a Uint16|
94
102
 
103
+ Examples:
104
+
105
+ ```grain
106
+ Uint16.fromInt16(1uS) == 1uS
107
+ ```
108
+
109
+ ```grain
110
+ Uint16.fromInt16(-1uS) == 65535uS
111
+ ```
112
+
95
113
  ### Uint16.**incr**
96
114
 
97
115
  <details disabled>
@@ -100,7 +118,7 @@ No other changes yet.
100
118
  </details>
101
119
 
102
120
  ```grain
103
- incr : (value: Uint16) => Uint16
121
+ incr: (value: Uint16) => Uint16
104
122
  ```
105
123
 
106
124
  Increments the value by one.
@@ -117,6 +135,12 @@ Returns:
117
135
  |----|-----------|
118
136
  |`Uint16`|The incremented value|
119
137
 
138
+ Examples:
139
+
140
+ ```grain
141
+ Uint16.incr(1uS) == 2uS
142
+ ```
143
+
120
144
  ### Uint16.**decr**
121
145
 
122
146
  <details disabled>
@@ -125,7 +149,7 @@ No other changes yet.
125
149
  </details>
126
150
 
127
151
  ```grain
128
- decr : (value: Uint16) => Uint16
152
+ decr: (value: Uint16) => Uint16
129
153
  ```
130
154
 
131
155
  Decrements the value by one.
@@ -142,6 +166,16 @@ Returns:
142
166
  |----|-----------|
143
167
  |`Uint16`|The decremented value|
144
168
 
169
+ Examples:
170
+
171
+ ```grain
172
+ Uint16.decr(1uS) == 0uS
173
+ ```
174
+
175
+ ```grain
176
+ Uint16.decr(0uS) == 65535uS
177
+ ```
178
+
145
179
  ### Uint16.**(+)**
146
180
 
147
181
  <details disabled>
@@ -150,7 +184,7 @@ No other changes yet.
150
184
  </details>
151
185
 
152
186
  ```grain
153
- (+) : (x: Uint16, y: Uint16) => Uint16
187
+ (+): (x: Uint16, y: Uint16) => Uint16
154
188
  ```
155
189
 
156
190
  Computes the sum of its operands.
@@ -168,6 +202,13 @@ Returns:
168
202
  |----|-----------|
169
203
  |`Uint16`|The sum of the two operands|
170
204
 
205
+ Examples:
206
+
207
+ ```grain
208
+ use Uint16.{ (+) }
209
+ assert 1uS + 1uS == 2uS
210
+ ```
211
+
171
212
  ### Uint16.**(-)**
172
213
 
173
214
  <details disabled>
@@ -176,7 +217,7 @@ No other changes yet.
176
217
  </details>
177
218
 
178
219
  ```grain
179
- (-) : (x: Uint16, y: Uint16) => Uint16
220
+ (-): (x: Uint16, y: Uint16) => Uint16
180
221
  ```
181
222
 
182
223
  Computes the difference of its operands.
@@ -194,6 +235,13 @@ Returns:
194
235
  |----|-----------|
195
236
  |`Uint16`|The difference of the two operands|
196
237
 
238
+ Examples:
239
+
240
+ ```grain
241
+ use Uint16.{ (-) }
242
+ assert 2uS - 1uS == 1uS
243
+ ```
244
+
197
245
  ### Uint16.**(*)**
198
246
 
199
247
  <details disabled>
@@ -202,7 +250,7 @@ No other changes yet.
202
250
  </details>
203
251
 
204
252
  ```grain
205
- (*) : (x: Uint16, y: Uint16) => Uint16
253
+ (*): (x: Uint16, y: Uint16) => Uint16
206
254
  ```
207
255
 
208
256
  Computes the product of its operands.
@@ -220,6 +268,13 @@ Returns:
220
268
  |----|-----------|
221
269
  |`Uint16`|The product of the two operands|
222
270
 
271
+ Examples:
272
+
273
+ ```grain
274
+ use Uint16.{ (*) }
275
+ assert 2uS * 2uS == 4uS
276
+ ```
277
+
223
278
  ### Uint16.**(/)**
224
279
 
225
280
  <details disabled>
@@ -228,7 +283,7 @@ No other changes yet.
228
283
  </details>
229
284
 
230
285
  ```grain
231
- (/) : (x: Uint16, y: Uint16) => Uint16
286
+ (/): (x: Uint16, y: Uint16) => Uint16
232
287
  ```
233
288
 
234
289
  Computes the quotient of its operands.
@@ -246,6 +301,13 @@ Returns:
246
301
  |----|-----------|
247
302
  |`Uint16`|The quotient of its operands|
248
303
 
304
+ Examples:
305
+
306
+ ```grain
307
+ use Uint16.{ (/) }
308
+ assert 5uS / 2uS == 2uS
309
+ ```
310
+
249
311
  ### Uint16.**rem**
250
312
 
251
313
  <details disabled>
@@ -254,7 +316,7 @@ No other changes yet.
254
316
  </details>
255
317
 
256
318
  ```grain
257
- rem : (x: Uint16, y: Uint16) => Uint16
319
+ rem: (x: Uint16, y: Uint16) => Uint16
258
320
  ```
259
321
 
260
322
  Computes the remainder of the division of its operands.
@@ -272,6 +334,12 @@ Returns:
272
334
  |----|-----------|
273
335
  |`Uint16`|The remainder of its operands|
274
336
 
337
+ Examples:
338
+
339
+ ```grain
340
+ Uint16.rem(5uS, 2uS) == 1uS
341
+ ```
342
+
275
343
  ### Uint16.**(<<)**
276
344
 
277
345
  <details disabled>
@@ -280,7 +348,7 @@ No other changes yet.
280
348
  </details>
281
349
 
282
350
  ```grain
283
- (<<) : (value: Uint16, amount: Uint16) => Uint16
351
+ (<<): (value: Uint16, amount: Uint16) => Uint16
284
352
  ```
285
353
 
286
354
  Shifts the bits of the value left by the given number of bits.
@@ -298,6 +366,13 @@ Returns:
298
366
  |----|-----------|
299
367
  |`Uint16`|The shifted value|
300
368
 
369
+ Examples:
370
+
371
+ ```grain
372
+ use Uint16.{ (<<) }
373
+ assert (5uS << 1uS) == 10uS
374
+ ```
375
+
301
376
  ### Uint16.**(>>>)**
302
377
 
303
378
  <details disabled>
@@ -306,7 +381,7 @@ No other changes yet.
306
381
  </details>
307
382
 
308
383
  ```grain
309
- (>>>) : (value: Uint16, amount: Uint16) => Uint16
384
+ (>>>): (value: Uint16, amount: Uint16) => Uint16
310
385
  ```
311
386
 
312
387
  Shifts the bits of the value right by the given number of bits.
@@ -324,6 +399,13 @@ Returns:
324
399
  |----|-----------|
325
400
  |`Uint16`|The shifted value|
326
401
 
402
+ Examples:
403
+
404
+ ```grain
405
+ use Uint16.{ (>>>) }
406
+ assert (5uS >>> 1uS) == 2uS
407
+ ```
408
+
327
409
  ### Uint16.**(==)**
328
410
 
329
411
  <details disabled>
@@ -332,7 +414,7 @@ No other changes yet.
332
414
  </details>
333
415
 
334
416
  ```grain
335
- (==) : (x: Uint16, y: Uint16) => Bool
417
+ (==): (x: Uint16, y: Uint16) => Bool
336
418
  ```
337
419
 
338
420
  Checks if the first value is equal to the second value.
@@ -350,6 +432,13 @@ Returns:
350
432
  |----|-----------|
351
433
  |`Bool`|`true` if the first value is equal to the second value or `false` otherwise|
352
434
 
435
+ Examples:
436
+
437
+ ```grain
438
+ use Uint16.{ (==) }
439
+ assert 1uS == 1uS
440
+ ```
441
+
353
442
  ### Uint16.**(!=)**
354
443
 
355
444
  <details disabled>
@@ -358,7 +447,7 @@ No other changes yet.
358
447
  </details>
359
448
 
360
449
  ```grain
361
- (!=) : (x: Uint16, y: Uint16) => Bool
450
+ (!=): (x: Uint16, y: Uint16) => Bool
362
451
  ```
363
452
 
364
453
  Checks if the first value is not equal to the second value.
@@ -376,6 +465,13 @@ Returns:
376
465
  |----|-----------|
377
466
  |`Bool`|`true` if the first value is not equal to the second value or `false` otherwise|
378
467
 
468
+ Examples:
469
+
470
+ ```grain
471
+ use Uint16.{ (!=) }
472
+ assert 1uS != 3uS
473
+ ```
474
+
379
475
  ### Uint16.**(<)**
380
476
 
381
477
  <details disabled>
@@ -384,7 +480,7 @@ No other changes yet.
384
480
  </details>
385
481
 
386
482
  ```grain
387
- (<) : (x: Uint16, y: Uint16) => Bool
483
+ (<): (x: Uint16, y: Uint16) => Bool
388
484
  ```
389
485
 
390
486
  Checks if the first value is less than the second value.
@@ -402,6 +498,13 @@ Returns:
402
498
  |----|-----------|
403
499
  |`Bool`|`true` if the first value is less than the second value or `false` otherwise|
404
500
 
501
+ Examples:
502
+
503
+ ```grain
504
+ use Uint16.{ (<) }
505
+ assert 1uS < 5uS
506
+ ```
507
+
405
508
  ### Uint16.**(>)**
406
509
 
407
510
  <details disabled>
@@ -410,7 +513,7 @@ No other changes yet.
410
513
  </details>
411
514
 
412
515
  ```grain
413
- (>) : (x: Uint16, y: Uint16) => Bool
516
+ (>): (x: Uint16, y: Uint16) => Bool
414
517
  ```
415
518
 
416
519
  Checks if the first value is greater than the second value.
@@ -428,6 +531,13 @@ Returns:
428
531
  |----|-----------|
429
532
  |`Bool`|`true` if the first value is greater than the second value or `false` otherwise|
430
533
 
534
+ Examples:
535
+
536
+ ```grain
537
+ use Uint16.{ (>) }
538
+ assert 4uS > 2uS
539
+ ```
540
+
431
541
  ### Uint16.**(<=)**
432
542
 
433
543
  <details disabled>
@@ -436,7 +546,7 @@ No other changes yet.
436
546
  </details>
437
547
 
438
548
  ```grain
439
- (<=) : (x: Uint16, y: Uint16) => Bool
549
+ (<=): (x: Uint16, y: Uint16) => Bool
440
550
  ```
441
551
 
442
552
  Checks if the first value is less than or equal to the second value.
@@ -454,6 +564,18 @@ Returns:
454
564
  |----|-----------|
455
565
  |`Bool`|`true` if the first value is less than or equal to the second value or `false` otherwise|
456
566
 
567
+ Examples:
568
+
569
+ ```grain
570
+ use Uint16.{ (<=) }
571
+ assert 1uS <= 2uS
572
+ ```
573
+
574
+ ```grain
575
+ use Uint16.{ (<=) }
576
+ assert 1uS <= 1uS
577
+ ```
578
+
457
579
  ### Uint16.**(>=)**
458
580
 
459
581
  <details disabled>
@@ -462,7 +584,7 @@ No other changes yet.
462
584
  </details>
463
585
 
464
586
  ```grain
465
- (>=) : (x: Uint16, y: Uint16) => Bool
587
+ (>=): (x: Uint16, y: Uint16) => Bool
466
588
  ```
467
589
 
468
590
  Checks if the first value is greater than or equal to the second value.
@@ -480,6 +602,18 @@ Returns:
480
602
  |----|-----------|
481
603
  |`Bool`|`true` if the first value is greater than or equal to the second value or `false` otherwise|
482
604
 
605
+ Examples:
606
+
607
+ ```grain
608
+ use Uint16.{ (>=) }
609
+ assert 3uS >= 2uS
610
+ ```
611
+
612
+ ```grain
613
+ use Uint16.{ (>=) }
614
+ assert 1uS >= 1uS
615
+ ```
616
+
483
617
  ### Uint16.**lnot**
484
618
 
485
619
  <details disabled>
@@ -488,7 +622,7 @@ No other changes yet.
488
622
  </details>
489
623
 
490
624
  ```grain
491
- lnot : (value: Uint16) => Uint16
625
+ lnot: (value: Uint16) => Uint16
492
626
  ```
493
627
 
494
628
  Computes the bitwise NOT of the given value.
@@ -505,6 +639,12 @@ Returns:
505
639
  |----|-----------|
506
640
  |`Uint16`|Containing the inverted bits of the given value|
507
641
 
642
+ Examples:
643
+
644
+ ```grain
645
+ Uint16.lnot(5uS) == 65530uS
646
+ ```
647
+
508
648
  ### Uint16.**(&)**
509
649
 
510
650
  <details disabled>
@@ -513,7 +653,7 @@ No other changes yet.
513
653
  </details>
514
654
 
515
655
  ```grain
516
- (&) : (x: Uint16, y: Uint16) => Uint16
656
+ (&): (x: Uint16, y: Uint16) => Uint16
517
657
  ```
518
658
 
519
659
  Computes the bitwise AND (`&`) on the given operands.
@@ -531,6 +671,13 @@ Returns:
531
671
  |----|-----------|
532
672
  |`Uint16`|Containing a `1` in each bit position for which the corresponding bits of both operands are `1`|
533
673
 
674
+ Examples:
675
+
676
+ ```grain
677
+ use Uint16.{ (&) }
678
+ assert (3uS & 4uS) == 0uS
679
+ ```
680
+
534
681
  ### Uint16.**(|)**
535
682
 
536
683
  <details disabled>
@@ -539,7 +686,7 @@ No other changes yet.
539
686
  </details>
540
687
 
541
688
  ```grain
542
- (|) : (x: Uint16, y: Uint16) => Uint16
689
+ (|): (x: Uint16, y: Uint16) => Uint16
543
690
  ```
544
691
 
545
692
  Computes the bitwise OR (`|`) on the given operands.
@@ -557,6 +704,13 @@ Returns:
557
704
  |----|-----------|
558
705
  |`Uint16`|Containing a `1` in each bit position for which the corresponding bits of either or both operands are `1`|
559
706
 
707
+ Examples:
708
+
709
+ ```grain
710
+ use Uint16.{ (|) }
711
+ assert (3uS | 4uS) == 7uS
712
+ ```
713
+
560
714
  ### Uint16.**(^)**
561
715
 
562
716
  <details disabled>
@@ -565,7 +719,7 @@ No other changes yet.
565
719
  </details>
566
720
 
567
721
  ```grain
568
- (^) : (x: Uint16, y: Uint16) => Uint16
722
+ (^): (x: Uint16, y: Uint16) => Uint16
569
723
  ```
570
724
 
571
725
  Computes the bitwise XOR (`^`) on the given operands.
@@ -583,3 +737,10 @@ Returns:
583
737
  |----|-----------|
584
738
  |`Uint16`|Containing a `1` in each bit position for which the corresponding bits of either but not both operands are `1`|
585
739
 
740
+ Examples:
741
+
742
+ ```grain
743
+ use Uint16.{ (^) }
744
+ assert (3uS ^ 5uS) == 6uS
745
+ ```
746
+
package/uint32.gr CHANGED
@@ -6,6 +6,12 @@
6
6
  */
7
7
  module Uint32
8
8
 
9
+ from "runtime/unsafe/offsets" include Offsets
10
+ use Offsets.{
11
+ _UINT32_VALUE_OFFSET as _VALUE_OFFSET,
12
+ _INT32_VALUE_OFFSET,
13
+ _FLOAT32_VALUE_OFFSET,
14
+ }
9
15
  from "runtime/unsafe/wasmi32" include WasmI32
10
16
  use WasmI32.{ (+), (-), (*), (&), (|), (^), (<<), (>>>), (==), (!=) }
11
17
  from "runtime/unsafe/wasmi64" include WasmI64
@@ -16,9 +22,6 @@ use Numbers.{ reducedUnsignedInteger, coerceNumberToUnsignedWasmI32 }
16
22
  from "runtime/dataStructures" include DataStructures
17
23
  use DataStructures.{ newUint32 }
18
24
 
19
- @unsafe
20
- let _VALUE_OFFSET = 4n
21
-
22
25
  /**
23
26
  * Converts a Number to a Uint32.
24
27
  *
@@ -60,7 +63,25 @@ provide let toNumber = (value: Uint32) => {
60
63
  */
61
64
  @unsafe
62
65
  provide let fromInt32 = (number: Int32) => {
63
- let x = WasmI32.load(WasmI32.fromGrain(number), _VALUE_OFFSET)
66
+ let x = WasmI32.load(WasmI32.fromGrain(number), _INT32_VALUE_OFFSET)
67
+ let result = newUint32(x)
68
+ WasmI32.toGrain(result): Uint32
69
+ }
70
+
71
+ /**
72
+ * Interprets a Float32 as an Uint32.
73
+ *
74
+ * @param value: The value to convert
75
+ * @returns The Float32 interpreted as an Uint32
76
+ *
77
+ * @example assert Uint32.reinterpretFloat32(1.0f) == 1065353216ul
78
+ * @example assert Uint32.reinterpretFloat32(-1.0f) == 3212836864ul
79
+ *
80
+ * @since v0.7.0
81
+ */
82
+ @unsafe
83
+ provide let reinterpretFloat32 = (value: Float32) => {
84
+ let x = WasmI32.load(WasmI32.fromGrain(value), _FLOAT32_VALUE_OFFSET)
64
85
  let result = newUint32(x)
65
86
  WasmI32.toGrain(result): Uint32
66
87
  }