@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.
Files changed (137) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/LICENSE +1 -1
  3. package/README.md +2 -2
  4. package/array.gr +55 -7
  5. package/array.md +606 -560
  6. package/bigint.md +228 -228
  7. package/buffer.gr +85 -53
  8. package/buffer.md +442 -319
  9. package/bytes.gr +112 -35
  10. package/bytes.md +299 -219
  11. package/char.gr +201 -99
  12. package/char.md +447 -120
  13. package/exception.gr +11 -11
  14. package/exception.md +29 -4
  15. package/float32.gr +327 -3
  16. package/float32.md +698 -111
  17. package/float64.gr +320 -3
  18. package/float64.md +698 -111
  19. package/fs.gr +1082 -0
  20. package/fs.md +630 -0
  21. package/hash.gr +142 -88
  22. package/hash.md +105 -17
  23. package/int16.md +178 -178
  24. package/int32.gr +26 -5
  25. package/int32.md +266 -231
  26. package/int64.gr +27 -2
  27. package/int64.md +266 -231
  28. package/int8.md +178 -178
  29. package/json.gr +366 -51
  30. package/json.md +431 -15
  31. package/list.gr +328 -31
  32. package/list.md +759 -336
  33. package/map.gr +20 -12
  34. package/map.md +266 -260
  35. package/marshal.gr +41 -40
  36. package/marshal.md +14 -14
  37. package/number.gr +278 -35
  38. package/number.md +688 -269
  39. package/option.md +162 -162
  40. package/package.json +5 -3
  41. package/path.gr +48 -0
  42. package/path.md +180 -89
  43. package/pervasives.gr +2 -2
  44. package/pervasives.md +275 -275
  45. package/priorityqueue.gr +7 -7
  46. package/priorityqueue.md +131 -131
  47. package/queue.gr +183 -29
  48. package/queue.md +404 -148
  49. package/random.md +43 -43
  50. package/range.gr +4 -4
  51. package/range.md +42 -42
  52. package/rational.md +123 -123
  53. package/regex.gr +52 -51
  54. package/regex.md +102 -102
  55. package/result.md +118 -118
  56. package/runtime/atof/common.md +39 -39
  57. package/runtime/atof/decimal.gr +6 -6
  58. package/runtime/atof/decimal.md +14 -14
  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 +8 -8
  71. package/runtime/dataStructures.md +211 -211
  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 +8 -8
  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 +13 -13
  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 +348 -342
  98. package/runtime/string.gr +37 -105
  99. package/runtime/string.md +20 -26
  100. package/runtime/unsafe/constants.md +24 -24
  101. package/runtime/unsafe/conv.md +19 -19
  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 +147 -147
  117. package/set.gr +18 -11
  118. package/set.md +253 -247
  119. package/stack.gr +171 -2
  120. package/stack.md +371 -89
  121. package/string.gr +352 -557
  122. package/string.md +298 -255
  123. package/uint16.md +170 -170
  124. package/uint32.gr +25 -4
  125. package/uint32.md +249 -214
  126. package/uint64.gr +25 -5
  127. package/uint64.md +249 -214
  128. package/uint8.md +170 -170
  129. package/uri.gr +57 -53
  130. package/uri.md +88 -89
  131. package/wasi/file.gr +67 -59
  132. package/wasi/file.md +308 -308
  133. package/wasi/process.md +26 -26
  134. package/wasi/random.md +12 -12
  135. package/wasi/time.md +16 -16
  136. package/runtime/utils/printing.gr +0 -60
  137. package/runtime/utils/printing.md +0 -26
package/float32.md CHANGED
@@ -41,7 +41,7 @@ No other changes yet.
41
41
  </details>
42
42
 
43
43
  ```grain
44
- infinity : Float32
44
+ infinity: Float32
45
45
  ```
46
46
 
47
47
  Infinity represented as a Float32 value.
@@ -55,7 +55,7 @@ No other changes yet.
55
55
  </details>
56
56
 
57
57
  ```grain
58
- nan : Float32
58
+ nan: Float32
59
59
  ```
60
60
 
61
61
  NaN (Not a Number) represented as a Float32 value.
@@ -69,7 +69,7 @@ No other changes yet.
69
69
  </details>
70
70
 
71
71
  ```grain
72
- pi : Float32
72
+ pi: Float32
73
73
  ```
74
74
 
75
75
  Pi represented as a Float32 value.
@@ -82,7 +82,7 @@ No other changes yet.
82
82
  </details>
83
83
 
84
84
  ```grain
85
- tau : Float32
85
+ tau: Float32
86
86
  ```
87
87
 
88
88
  Tau represented as a Float32 value.
@@ -95,7 +95,7 @@ No other changes yet.
95
95
  </details>
96
96
 
97
97
  ```grain
98
- e : Float32
98
+ e: Float32
99
99
  ```
100
100
 
101
101
  Euler's number represented as a Float32 value.
@@ -108,22 +108,22 @@ No other changes yet.
108
108
  </details>
109
109
 
110
110
  ```grain
111
- fromNumber : (number: Number) => Float32
111
+ fromNumber: (number: Number) => Float32
112
112
  ```
113
113
 
114
114
  Converts a Number to a Float32.
115
115
 
116
116
  Parameters:
117
117
 
118
- |param|type|description|
119
- |-----|----|-----------|
120
- |`number`|`Number`|The value to convert|
118
+ | param | type | description |
119
+ | -------- | -------- | -------------------- |
120
+ | `number` | `Number` | The value to convert |
121
121
 
122
122
  Returns:
123
123
 
124
- |type|description|
125
- |----|-----------|
126
- |`Float32`|The Number represented as a Float32|
124
+ | type | description |
125
+ | --------- | ----------------------------------- |
126
+ | `Float32` | The Number represented as a Float32 |
127
127
 
128
128
  ### Float32.**toNumber**
129
129
 
@@ -133,22 +133,92 @@ No other changes yet.
133
133
  </details>
134
134
 
135
135
  ```grain
136
- toNumber : (float: Float32) => Number
136
+ toNumber: (float: Float32) => Number
137
137
  ```
138
138
 
139
139
  Converts a Float32 to a Number.
140
140
 
141
141
  Parameters:
142
142
 
143
- |param|type|description|
144
- |-----|----|-----------|
145
- |`float`|`Float32`|The value to convert|
143
+ | param | type | description |
144
+ | ------- | --------- | -------------------- |
145
+ | `float` | `Float32` | The value to convert |
146
146
 
147
147
  Returns:
148
148
 
149
- |type|description|
150
- |----|-----------|
151
- |`Number`|The Float32 represented as a Number|
149
+ | type | description |
150
+ | -------- | ----------------------------------- |
151
+ | `Number` | The Float32 represented as a Number |
152
+
153
+ ### Float32.**reinterpretInt32**
154
+
155
+ <details disabled>
156
+ <summary tabindex="-1">Added in <code>0.7.0</code></summary>
157
+ No other changes yet.
158
+ </details>
159
+
160
+ ```grain
161
+ reinterpretInt32: (value: Int32) => Float32
162
+ ```
163
+
164
+ Interprets an Int32 as a Float32.
165
+
166
+ Parameters:
167
+
168
+ | param | type | description |
169
+ | ------- | ------- | -------------------- |
170
+ | `value` | `Int32` | The value to convert |
171
+
172
+ Returns:
173
+
174
+ | type | description |
175
+ | --------- | ----------------------------------- |
176
+ | `Float32` | The Int32 interpreted as an Float32 |
177
+
178
+ Examples:
179
+
180
+ ```grain
181
+ assert Float32.reinterpretInt32(1065353216l) == 1.0f
182
+ ```
183
+
184
+ ```grain
185
+ assert Float32.reinterpretInt32(-1082130432l) == -1.0f
186
+ ```
187
+
188
+ ### Float32.**reinterpretUint32**
189
+
190
+ <details disabled>
191
+ <summary tabindex="-1">Added in <code>0.7.0</code></summary>
192
+ No other changes yet.
193
+ </details>
194
+
195
+ ```grain
196
+ reinterpretUint32: (value: Uint32) => Float32
197
+ ```
198
+
199
+ Interprets an Uint32 as a Float32.
200
+
201
+ Parameters:
202
+
203
+ | param | type | description |
204
+ | ------- | -------- | -------------------- |
205
+ | `value` | `Uint32` | The value to convert |
206
+
207
+ Returns:
208
+
209
+ | type | description |
210
+ | --------- | ------------------------------------ |
211
+ | `Float32` | The Uint32 interpreted as an Float32 |
212
+
213
+ Examples:
214
+
215
+ ```grain
216
+ assert Float32.reinterpretUint32(1065353216ul) == 1.0f
217
+ ```
218
+
219
+ ```grain
220
+ assert Float32.reinterpretUint32(3212836864ul) == -1.0f
221
+ ```
152
222
 
153
223
  ### Float32.**(+)**
154
224
 
@@ -165,23 +235,23 @@ Returns:
165
235
  </details>
166
236
 
167
237
  ```grain
168
- (+) : (x: Float32, y: Float32) => Float32
238
+ (+): (x: Float32, y: Float32) => Float32
169
239
  ```
170
240
 
171
241
  Computes the sum of its operands.
172
242
 
173
243
  Parameters:
174
244
 
175
- |param|type|description|
176
- |-----|----|-----------|
177
- |`x`|`Float32`|The first operand|
178
- |`y`|`Float32`|The second operand|
245
+ | param | type | description |
246
+ | ----- | --------- | ------------------ |
247
+ | `x` | `Float32` | The first operand |
248
+ | `y` | `Float32` | The second operand |
179
249
 
180
250
  Returns:
181
251
 
182
- |type|description|
183
- |----|-----------|
184
- |`Float32`|The sum of the two operands|
252
+ | type | description |
253
+ | --------- | --------------------------- |
254
+ | `Float32` | The sum of the two operands |
185
255
 
186
256
  Examples:
187
257
 
@@ -205,23 +275,23 @@ assert 1.0f + 1.0f == 2.0f
205
275
  </details>
206
276
 
207
277
  ```grain
208
- (-) : (x: Float32, y: Float32) => Float32
278
+ (-): (x: Float32, y: Float32) => Float32
209
279
  ```
210
280
 
211
281
  Computes the difference of its operands.
212
282
 
213
283
  Parameters:
214
284
 
215
- |param|type|description|
216
- |-----|----|-----------|
217
- |`x`|`Float32`|The first operand|
218
- |`y`|`Float32`|The second operand|
285
+ | param | type | description |
286
+ | ----- | --------- | ------------------ |
287
+ | `x` | `Float32` | The first operand |
288
+ | `y` | `Float32` | The second operand |
219
289
 
220
290
  Returns:
221
291
 
222
- |type|description|
223
- |----|-----------|
224
- |`Float32`|The difference of the two operands|
292
+ | type | description |
293
+ | --------- | ---------------------------------- |
294
+ | `Float32` | The difference of the two operands |
225
295
 
226
296
  Examples:
227
297
 
@@ -245,23 +315,23 @@ assert 1.0f - 1.0f == 0.0f
245
315
  </details>
246
316
 
247
317
  ```grain
248
- (*) : (x: Float32, y: Float32) => Float32
318
+ (*): (x: Float32, y: Float32) => Float32
249
319
  ```
250
320
 
251
321
  Computes the product of its operands.
252
322
 
253
323
  Parameters:
254
324
 
255
- |param|type|description|
256
- |-----|----|-----------|
257
- |`x`|`Float32`|The first operand|
258
- |`y`|`Float32`|The second operand|
325
+ | param | type | description |
326
+ | ----- | --------- | ------------------ |
327
+ | `x` | `Float32` | The first operand |
328
+ | `y` | `Float32` | The second operand |
259
329
 
260
330
  Returns:
261
331
 
262
- |type|description|
263
- |----|-----------|
264
- |`Float32`|The product of the two operands|
332
+ | type | description |
333
+ | --------- | ------------------------------- |
334
+ | `Float32` | The product of the two operands |
265
335
 
266
336
  Examples:
267
337
 
@@ -285,23 +355,23 @@ assert 2.0f * 2.0f == 4.0f
285
355
  </details>
286
356
 
287
357
  ```grain
288
- (/) : (x: Float32, y: Float32) => Float32
358
+ (/): (x: Float32, y: Float32) => Float32
289
359
  ```
290
360
 
291
361
  Computes the quotient of its operands.
292
362
 
293
363
  Parameters:
294
364
 
295
- |param|type|description|
296
- |-----|----|-----------|
297
- |`x`|`Float32`|The first operand|
298
- |`y`|`Float32`|The second operand|
365
+ | param | type | description |
366
+ | ----- | --------- | ------------------ |
367
+ | `x` | `Float32` | The first operand |
368
+ | `y` | `Float32` | The second operand |
299
369
 
300
370
  Returns:
301
371
 
302
- |type|description|
303
- |----|-----------|
304
- |`Float32`|The quotient of the two operands|
372
+ | type | description |
373
+ | --------- | -------------------------------- |
374
+ | `Float32` | The quotient of the two operands |
305
375
 
306
376
  Examples:
307
377
 
@@ -310,6 +380,39 @@ use Float32.{ (/) }
310
380
  assert 10.0f / 4.0f == 2.5f
311
381
  ```
312
382
 
383
+ ### Float32.**(\*\*)**
384
+
385
+ <details disabled>
386
+ <summary tabindex="-1">Added in <code>0.7.0</code></summary>
387
+ No other changes yet.
388
+ </details>
389
+
390
+ ```grain
391
+ (**): (base: Float32, power: Float32) => Float32
392
+ ```
393
+
394
+ Computes the exponentiation of the given base and power.
395
+
396
+ Parameters:
397
+
398
+ | param | type | description |
399
+ | ------- | --------- | ------------------ |
400
+ | `base` | `Float32` | The base float |
401
+ | `power` | `Float32` | The exponent float |
402
+
403
+ Returns:
404
+
405
+ | type | description |
406
+ | --------- | ---------------------------------- |
407
+ | `Float32` | The base raised to the given power |
408
+
409
+ Examples:
410
+
411
+ ```grain
412
+ use Float64.{ (**) }
413
+ assert 2.0f ** 2.0f == 4.0f
414
+ ```
415
+
313
416
  ### Float32.**(<)**
314
417
 
315
418
  <details>
@@ -325,23 +428,23 @@ assert 10.0f / 4.0f == 2.5f
325
428
  </details>
326
429
 
327
430
  ```grain
328
- (<) : (x: Float32, y: Float32) => Bool
431
+ (<): (x: Float32, y: Float32) => Bool
329
432
  ```
330
433
 
331
434
  Checks if the first value is less than the second value.
332
435
 
333
436
  Parameters:
334
437
 
335
- |param|type|description|
336
- |-----|----|-----------|
337
- |`x`|`Float32`|The first value|
338
- |`y`|`Float32`|The second value|
438
+ | param | type | description |
439
+ | ----- | --------- | ---------------- |
440
+ | `x` | `Float32` | The first value |
441
+ | `y` | `Float32` | The second value |
339
442
 
340
443
  Returns:
341
444
 
342
- |type|description|
343
- |----|-----------|
344
- |`Bool`|`true` if the first value is less than the second value or `false` otherwise|
445
+ | type | description |
446
+ | ------ | ---------------------------------------------------------------------------- |
447
+ | `Bool` | `true` if the first value is less than the second value or `false` otherwise |
345
448
 
346
449
  Examples:
347
450
 
@@ -365,23 +468,23 @@ assert 1.0f < 2.0f
365
468
  </details>
366
469
 
367
470
  ```grain
368
- (>) : (x: Float32, y: Float32) => Bool
471
+ (>): (x: Float32, y: Float32) => Bool
369
472
  ```
370
473
 
371
474
  Checks if the first value is greater than the second value.
372
475
 
373
476
  Parameters:
374
477
 
375
- |param|type|description|
376
- |-----|----|-----------|
377
- |`x`|`Float32`|The first value|
378
- |`y`|`Float32`|The second value|
478
+ | param | type | description |
479
+ | ----- | --------- | ---------------- |
480
+ | `x` | `Float32` | The first value |
481
+ | `y` | `Float32` | The second value |
379
482
 
380
483
  Returns:
381
484
 
382
- |type|description|
383
- |----|-----------|
384
- |`Bool`|`true` if the first value is greater than the second value or `false` otherwise|
485
+ | type | description |
486
+ | ------ | ------------------------------------------------------------------------------- |
487
+ | `Bool` | `true` if the first value is greater than the second value or `false` otherwise |
385
488
 
386
489
  Examples:
387
490
 
@@ -405,23 +508,23 @@ assert 2.0f > 1.0f
405
508
  </details>
406
509
 
407
510
  ```grain
408
- (<=) : (x: Float32, y: Float32) => Bool
511
+ (<=): (x: Float32, y: Float32) => Bool
409
512
  ```
410
513
 
411
514
  Checks if the first value is less than or equal to the second value.
412
515
 
413
516
  Parameters:
414
517
 
415
- |param|type|description|
416
- |-----|----|-----------|
417
- |`x`|`Float32`|The first value|
418
- |`y`|`Float32`|The second value|
518
+ | param | type | description |
519
+ | ----- | --------- | ---------------- |
520
+ | `x` | `Float32` | The first value |
521
+ | `y` | `Float32` | The second value |
419
522
 
420
523
  Returns:
421
524
 
422
- |type|description|
423
- |----|-----------|
424
- |`Bool`|`true` if the first value is less than or equal to the second value or `false` otherwise|
525
+ | type | description |
526
+ | ------ | ---------------------------------------------------------------------------------------- |
527
+ | `Bool` | `true` if the first value is less than or equal to the second value or `false` otherwise |
425
528
 
426
529
  Examples:
427
530
 
@@ -450,23 +553,23 @@ assert -2.0f <= -2.0f
450
553
  </details>
451
554
 
452
555
  ```grain
453
- (>=) : (x: Float32, y: Float32) => Bool
556
+ (>=): (x: Float32, y: Float32) => Bool
454
557
  ```
455
558
 
456
559
  Checks if the first value is greater than or equal to the second value.
457
560
 
458
561
  Parameters:
459
562
 
460
- |param|type|description|
461
- |-----|----|-----------|
462
- |`x`|`Float32`|The first value|
463
- |`y`|`Float32`|The second value|
563
+ | param | type | description |
564
+ | ----- | --------- | ---------------- |
565
+ | `x` | `Float32` | The first value |
566
+ | `y` | `Float32` | The second value |
464
567
 
465
568
  Returns:
466
569
 
467
- |type|description|
468
- |----|-----------|
469
- |`Bool`|`true` if the first value is greater than or equal to the second value or `false` otherwise|
570
+ | type | description |
571
+ | ------ | ------------------------------------------------------------------------------------------- |
572
+ | `Bool` | `true` if the first value is greater than or equal to the second value or `false` otherwise |
470
573
 
471
574
  Examples:
472
575
 
@@ -480,6 +583,54 @@ use Float32.{ (>=) }
480
583
  assert 3.0f >= 3.0f
481
584
  ```
482
585
 
586
+ ### Float32.**isFinite**
587
+
588
+ <details disabled>
589
+ <summary tabindex="-1">Added in <code>0.7.0</code></summary>
590
+ No other changes yet.
591
+ </details>
592
+
593
+ ```grain
594
+ isFinite: (x: Float32) => Bool
595
+ ```
596
+
597
+ Checks if a float is finite.
598
+ All values are finite exept for NaN, infinity or negative infinity.
599
+
600
+ Parameters:
601
+
602
+ | param | type | description |
603
+ | ----- | --------- | ------------------- |
604
+ | `x` | `Float32` | The number to check |
605
+
606
+ Returns:
607
+
608
+ | type | description |
609
+ | ------ | -------------------------------------------------- |
610
+ | `Bool` | `true` if the value is finite or `false` otherwise |
611
+
612
+ Examples:
613
+
614
+ ```grain
615
+ Float32.isFinite(0.5f)
616
+ ```
617
+
618
+ ```grain
619
+ Float32.isFinite(1.0f)
620
+ ```
621
+
622
+ ```grain
623
+ Float32.isFinite(Infinityf) == false
624
+ ```
625
+
626
+ ```grain
627
+ Float32.isFinite(-Infinityf) == false
628
+ ```
629
+
630
+ ```grain
631
+ Float32.isFinite(NaNf) == false
632
+ ```
633
+
483
634
  ### Float32.**isNaN**
484
635
 
485
636
  <details disabled>
@@ -488,22 +639,22 @@ No other changes yet.
488
639
  </details>
489
640
 
490
641
  ```grain
491
- isNaN : (x: Float32) => Bool
642
+ isNaN: (x: Float32) => Bool
492
643
  ```
493
644
 
494
645
  Checks if the value is a float NaN value (Not A Number).
495
646
 
496
647
  Parameters:
497
648
 
498
- |param|type|description|
499
- |-----|----|-----------|
500
- |`x`|`Float32`|The value to check|
649
+ | param | type | description |
650
+ | ----- | --------- | ------------------ |
651
+ | `x` | `Float32` | The value to check |
501
652
 
502
653
  Returns:
503
654
 
504
- |type|description|
505
- |----|-----------|
506
- |`Bool`|`true` if the value is NaN, otherwise `false`|
655
+ | type | description |
656
+ | ------ | --------------------------------------------- |
657
+ | `Bool` | `true` if the value is NaN, otherwise `false` |
507
658
 
508
659
  Examples:
509
660
 
@@ -535,22 +686,22 @@ No other changes yet.
535
686
  </details>
536
687
 
537
688
  ```grain
538
- isInfinite : (x: Float32) => Bool
689
+ isInfinite: (x: Float32) => Bool
539
690
  ```
540
691
 
541
692
  Checks if a float is infinite, that is either of positive or negative infinity.
542
693
 
543
694
  Parameters:
544
695
 
545
- |param|type|description|
546
- |-----|----|-----------|
547
- |`x`|`Float32`|The value to check|
696
+ | param | type | description |
697
+ | ----- | --------- | ------------------ |
698
+ | `x` | `Float32` | The value to check |
548
699
 
549
700
  Returns:
550
701
 
551
- |type|description|
552
- |----|-----------|
553
- |`Bool`|`true` if the value is infinite or `false` otherwise|
702
+ | type | description |
703
+ | ------ | ---------------------------------------------------- |
704
+ | `Bool` | `true` if the value is infinite or `false` otherwise |
554
705
 
555
706
  Examples:
556
707
 
@@ -574,6 +725,70 @@ Float32.isInfinite(0.5f) == false
574
725
  Float32.isInfinite(1.0f) == false
575
726
  ```
576
727
 
728
+ ### Float32.**min**
729
+
730
+ <details disabled>
731
+ <summary tabindex="-1">Added in <code>0.7.0</code></summary>
732
+ No other changes yet.
733
+ </details>
734
+
735
+ ```grain
736
+ min: (x: Float32, y: Float32) => Float32
737
+ ```
738
+
739
+ Returns the smaller of its operands.
740
+
741
+ Parameters:
742
+
743
+ | param | type | description |
744
+ | ----- | --------- | ------------------ |
745
+ | `x` | `Float32` | The first operand |
746
+ | `y` | `Float32` | The second operand |
747
+
748
+ Returns:
749
+
750
+ | type | description |
751
+ | --------- | ------------------------------- |
752
+ | `Float32` | The smaller of the two operands |
753
+
754
+ Examples:
755
+
756
+ ```grain
757
+ Float32.min(5.0f, 2.0f) == 2.0f
758
+ ```
759
+
760
+ ### Float32.**max**
761
+
762
+ <details disabled>
763
+ <summary tabindex="-1">Added in <code>0.7.0</code></summary>
764
+ No other changes yet.
765
+ </details>
766
+
767
+ ```grain
768
+ max: (x: Float32, y: Float32) => Float32
769
+ ```
770
+
771
+ Returns the larger of its operands.
772
+
773
+ Parameters:
774
+
775
+ | param | type | description |
776
+ | ----- | --------- | ------------------ |
777
+ | `x` | `Float32` | The first operand |
778
+ | `y` | `Float32` | The second operand |
779
+
780
+ Returns:
781
+
782
+ | type | description |
783
+ | --------- | ------------------------------ |
784
+ | `Float32` | The larger of the two operands |
785
+
786
+ Examples:
787
+
788
+ ```grain
789
+ Float32.max(5.0f, 2.0f) == 5.0f
790
+ ```
791
+
577
792
  ### Float32.**abs**
578
793
 
579
794
  <details disabled>
@@ -582,22 +797,22 @@ No other changes yet.
582
797
  </details>
583
798
 
584
799
  ```grain
585
- abs : (x: Float32) => Float32
800
+ abs: (x: Float32) => Float32
586
801
  ```
587
802
 
588
803
  Returns the absolute value. That is, it returns `x` if `x` is positive or zero and the negation of `x` if `x` is negative.
589
804
 
590
805
  Parameters:
591
806
 
592
- |param|type|description|
593
- |-----|----|-----------|
594
- |`x`|`Float32`|The operand|
807
+ | param | type | description |
808
+ | ----- | --------- | ----------- |
809
+ | `x` | `Float32` | The operand |
595
810
 
596
811
  Returns:
597
812
 
598
- |type|description|
599
- |----|-----------|
600
- |`Float32`|The absolute value of the operand|
813
+ | type | description |
814
+ | --------- | --------------------------------- |
815
+ | `Float32` | The absolute value of the operand |
601
816
 
602
817
  Examples:
603
818
 
@@ -617,22 +832,22 @@ No other changes yet.
617
832
  </details>
618
833
 
619
834
  ```grain
620
- neg : (x: Float32) => Float32
835
+ neg: (x: Float32) => Float32
621
836
  ```
622
837
 
623
838
  Returns the negation of its operand.
624
839
 
625
840
  Parameters:
626
841
 
627
- |param|type|description|
628
- |-----|----|-----------|
629
- |`x`|`Float32`|The operand|
842
+ | param | type | description |
843
+ | ----- | --------- | ----------- |
844
+ | `x` | `Float32` | The operand |
630
845
 
631
846
  Returns:
632
847
 
633
- |type|description|
634
- |----|-----------|
635
- |`Float32`|The negated operand|
848
+ | type | description |
849
+ | --------- | ------------------- |
850
+ | `Float32` | The negated operand |
636
851
 
637
852
  Examples:
638
853
 
@@ -644,3 +859,375 @@ Float32.neg(-1.0f) == 1.0f
644
859
  Float32.neg(1.0f) == -1.0f
645
860
  ```
646
861
 
862
+ ### Float32.**ceil**
863
+
864
+ <details disabled>
865
+ <summary tabindex="-1">Added in <code>0.7.0</code></summary>
866
+ No other changes yet.
867
+ </details>
868
+
869
+ ```grain
870
+ ceil: (x: Float32) => Float32
871
+ ```
872
+
873
+ Rounds its operand up to the next largest whole value.
874
+
875
+ Parameters:
876
+
877
+ | param | type | description |
878
+ | ----- | --------- | ------------------- |
879
+ | `x` | `Float32` | The operand to ceil |
880
+
881
+ Returns:
882
+
883
+ | type | description |
884
+ | --------- | ------------------------------------------- |
885
+ | `Float32` | The next largest whole value of the operand |
886
+
887
+ Examples:
888
+
889
+ ```grain
890
+ Float32.ceil(5.5f) == 6.0f
891
+ ```
892
+
893
+ ```grain
894
+ Float32.ceil(-5.5f) == -5.0f
895
+ ```
896
+
897
+ ### Float32.**floor**
898
+
899
+ <details disabled>
900
+ <summary tabindex="-1">Added in <code>0.7.0</code></summary>
901
+ No other changes yet.
902
+ </details>
903
+
904
+ ```grain
905
+ floor: (x: Float32) => Float32
906
+ ```
907
+
908
+ Rounds its operand down to the largest whole value less than the operand.
909
+
910
+ Parameters:
911
+
912
+ | param | type | description |
913
+ | ----- | --------- | -------------------- |
914
+ | `x` | `Float32` | The operand to floor |
915
+
916
+ Returns:
917
+
918
+ | type | description |
919
+ | --------- | --------------------------------------- |
920
+ | `Float32` | The previous whole value of the operand |
921
+
922
+ Examples:
923
+
924
+ ```grain
925
+ Float32.floor(5.5f) == 5.0f
926
+ ```
927
+
928
+ ```grain
929
+ Float32.floor(-5.5f) == -6.0f
930
+ ```
931
+
932
+ ### Float32.**trunc**
933
+
934
+ <details disabled>
935
+ <summary tabindex="-1">Added in <code>0.7.0</code></summary>
936
+ No other changes yet.
937
+ </details>
938
+
939
+ ```grain
940
+ trunc: (x: Float32) => Float32
941
+ ```
942
+
943
+ Returns the whole value part of its operand, removing any fractional value.
944
+
945
+ Parameters:
946
+
947
+ | param | type | description |
948
+ | ----- | --------- | ----------------------- |
949
+ | `x` | `Float32` | The operand to truncate |
950
+
951
+ Returns:
952
+
953
+ | type | description |
954
+ | --------- | ----------------------------------- |
955
+ | `Float32` | The whole value part of the operand |
956
+
957
+ Examples:
958
+
959
+ ```grain
960
+ Float32.trunc(5.5f) == 5.0f
961
+ ```
962
+
963
+ ### Float32.**round**
964
+
965
+ <details disabled>
966
+ <summary tabindex="-1">Added in <code>0.7.0</code></summary>
967
+ No other changes yet.
968
+ </details>
969
+
970
+ ```grain
971
+ round: (x: Float32) => Float32
972
+ ```
973
+
974
+ Returns its operand rounded to its nearest integer.
975
+
976
+ Parameters:
977
+
978
+ | param | type | description |
979
+ | ----- | --------- | -------------------- |
980
+ | `x` | `Float32` | The operand to round |
981
+
982
+ Returns:
983
+
984
+ | type | description |
985
+ | --------- | ---------------------------------- |
986
+ | `Float32` | The nearest integer to the operand |
987
+
988
+ Examples:
989
+
990
+ ```grain
991
+ Float32.round(5.5f) == 6.0f
992
+ ```
993
+
994
+ ```grain
995
+ Float32.round(5.4f) == 5.0f
996
+ ```
997
+
998
+ ```grain
999
+ Float32.round(-5.5f) == -6.0f
1000
+ ```
1001
+
1002
+ ```grain
1003
+ Float32.round(-5.4f) == -5.0f
1004
+ ```
1005
+
1006
+ ### Float32.**sqrt**
1007
+
1008
+ <details disabled>
1009
+ <summary tabindex="-1">Added in <code>0.7.0</code></summary>
1010
+ No other changes yet.
1011
+ </details>
1012
+
1013
+ ```grain
1014
+ sqrt: (x: Float32) => Float32
1015
+ ```
1016
+
1017
+ Computes the square root of its operand.
1018
+
1019
+ Parameters:
1020
+
1021
+ | param | type | description |
1022
+ | ----- | --------- | -------------------------- |
1023
+ | `x` | `Float32` | The operand to square root |
1024
+
1025
+ Returns:
1026
+
1027
+ | type | description |
1028
+ | --------- | ------------------------------ |
1029
+ | `Float32` | The square root of the operand |
1030
+
1031
+ Examples:
1032
+
1033
+ ```grain
1034
+ Float32.sqrt(25.0f) == 5.0f
1035
+ ```
1036
+
1037
+ ### Float32.**copySign**
1038
+
1039
+ <details disabled>
1040
+ <summary tabindex="-1">Added in <code>0.7.0</code></summary>
1041
+ No other changes yet.
1042
+ </details>
1043
+
1044
+ ```grain
1045
+ copySign: (x: Float32, y: Float32) => Float32
1046
+ ```
1047
+
1048
+ Copys the sign of the second operand to the first operand.
1049
+
1050
+ Parameters:
1051
+
1052
+ | param | type | description |
1053
+ | ----- | --------- | --------------------------------- |
1054
+ | `x` | `Float32` | The operand to modify |
1055
+ | `y` | `Float32` | The operand to copy the sign from |
1056
+
1057
+ Returns:
1058
+
1059
+ | type | description |
1060
+ | --------- | ----------------------------------------------------- |
1061
+ | `Float32` | The first operand with the sign of the second operand |
1062
+
1063
+ Examples:
1064
+
1065
+ ```grain
1066
+ Float32.copySign(2.0f, 1.0f) == 2.0f
1067
+ ```
1068
+
1069
+ ```grain
1070
+ Float32.copySign(3.0f, -1.0f) == -3.0f
1071
+ ```
1072
+
1073
+ ```grain
1074
+ Float32.copySign(-5.0f, 1.0f) == 5.0f
1075
+ ```
1076
+
1077
+ ### Float32.**isClose**
1078
+
1079
+ <details disabled>
1080
+ <summary tabindex="-1">Added in <code>0.7.0</code></summary>
1081
+ No other changes yet.
1082
+ </details>
1083
+
1084
+ ```grain
1085
+ isClose:
1086
+ (a: Float32, b: Float32, ?relativeTolerance: Float32,
1087
+ ?absoluteTolerance: Float32) => Bool
1088
+ ```
1089
+
1090
+ Determines whether two values are considered close to each other using a relative and absolute tolerance.
1091
+
1092
+ Parameters:
1093
+
1094
+ | param | type | description |
1095
+ | -------------------- | --------- | ----------------------------------------------------------------------------- |
1096
+ | `a` | `Float32` | The first value |
1097
+ | `b` | `Float32` | The second value |
1098
+ | `?relativeTolerance` | `Float32` | The maximum tolerance to use relative to the larger absolute value `a` or `b` |
1099
+ | `?absoluteTolerance` | `Float32` | The absolute tolerance to use, regardless of the values of `a` or `b` |
1100
+
1101
+ Returns:
1102
+
1103
+ | type | description |
1104
+ | ------ | ---------------------------------------------------------------------------- |
1105
+ | `Bool` | `true` if the values are considered close to each other or `false` otherwise |
1106
+
1107
+ Examples:
1108
+
1109
+ ```grain
1110
+ Float32.isClose(1.233f, 1.233f)
1111
+ ```
1112
+
1113
+ ```grain
1114
+ Float32.isClose(1.233f, 1.233000001f)
1115
+ ```
1116
+
1117
+ ```grain
1118
+ Float32.isClose(8.005f, 8.450f, absoluteTolerance=0.5f)
1119
+ ```
1120
+
1121
+ ```grain
1122
+ Float32.isClose(4.0f, 4.1f, relativeTolerance=0.025f)
1123
+ ```
1124
+
1125
+ ```grain
1126
+ Float32.isClose(1.233f, 1.24f) == false
1127
+ ```
1128
+
1129
+ ```grain
1130
+ Float32.isClose(1.233f, 1.4566f) == false
1131
+ ```
1132
+
1133
+ ```grain
1134
+ Float32.isClose(8.005f, 8.450f, absoluteTolerance=0.4f) == false
1135
+ ```
1136
+
1137
+ ```grain
1138
+ Float32.isClose(4.0f, 4.1f, relativeTolerance=0.024f) == false
1139
+ ```
1140
+
1141
+ ### Float32.**sin**
1142
+
1143
+ <details disabled>
1144
+ <summary tabindex="-1">Added in <code>0.7.0</code></summary>
1145
+ No other changes yet.
1146
+ </details>
1147
+
1148
+ ```grain
1149
+ sin: (radians: Float32) => Float32
1150
+ ```
1151
+
1152
+ Computes the sine of a float (in radians).
1153
+
1154
+ Parameters:
1155
+
1156
+ | param | type | description |
1157
+ | --------- | --------- | -------------------- |
1158
+ | `radians` | `Float32` | The input in radians |
1159
+
1160
+ Returns:
1161
+
1162
+ | type | description |
1163
+ | --------- | ----------------- |
1164
+ | `Float32` | The computed sine |
1165
+
1166
+ Examples:
1167
+
1168
+ ```grain
1169
+ Float32.sin(0.0f) == 0.0f
1170
+ ```
1171
+
1172
+ ### Float32.**cos**
1173
+
1174
+ <details disabled>
1175
+ <summary tabindex="-1">Added in <code>0.7.0</code></summary>
1176
+ No other changes yet.
1177
+ </details>
1178
+
1179
+ ```grain
1180
+ cos: (radians: Float32) => Float32
1181
+ ```
1182
+
1183
+ Computes the cosine of a float (in radians).
1184
+
1185
+ Parameters:
1186
+
1187
+ | param | type | description |
1188
+ | --------- | --------- | -------------------- |
1189
+ | `radians` | `Float32` | The input in radians |
1190
+
1191
+ Returns:
1192
+
1193
+ | type | description |
1194
+ | --------- | ------------------- |
1195
+ | `Float32` | The computed cosine |
1196
+
1197
+ Examples:
1198
+
1199
+ ```grain
1200
+ Float32.cos(0.0f) == 1.0f
1201
+ ```
1202
+
1203
+ ### Float32.**tan**
1204
+
1205
+ <details disabled>
1206
+ <summary tabindex="-1">Added in <code>0.7.0</code></summary>
1207
+ No other changes yet.
1208
+ </details>
1209
+
1210
+ ```grain
1211
+ tan: (radians: Float32) => Float32
1212
+ ```
1213
+
1214
+ Computes the tangent of a number (in radians).
1215
+
1216
+ Parameters:
1217
+
1218
+ | param | type | description |
1219
+ | --------- | --------- | -------------------- |
1220
+ | `radians` | `Float32` | The input in radians |
1221
+
1222
+ Returns:
1223
+
1224
+ | type | description |
1225
+ | --------- | -------------------- |
1226
+ | `Float32` | The computed tangent |
1227
+
1228
+ Examples:
1229
+
1230
+ ```grain
1231
+ Float32.tan(0.0f) == 0.0f
1232
+ ```
1233
+