@grain/stdlib 0.5.0 → 0.5.3
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 +41 -0
- package/array.gr +56 -1
- package/array.md +83 -0
- package/bigint.md +61 -61
- package/buffer.gr +33 -31
- package/buffer.md +1 -1
- package/bytes.md +1 -1
- package/exception.gr +28 -2
- package/exception.md +37 -0
- package/float32.gr +50 -30
- package/float32.md +69 -30
- package/float64.gr +55 -34
- package/float64.md +69 -30
- package/immutablepriorityqueue.gr +332 -0
- package/immutablepriorityqueue.md +248 -0
- package/int32.md +4 -4
- package/int64.md +4 -4
- package/list.gr +73 -0
- package/list.md +110 -0
- package/map.gr +1 -2
- package/map.md +1 -1
- package/marshal.gr +1058 -0
- package/marshal.md +76 -0
- package/number.gr +122 -0
- package/number.md +172 -0
- package/package.json +1 -1
- package/pervasives.gr +16 -5
- package/pervasives.md +28 -0
- package/priorityqueue.gr +241 -0
- package/priorityqueue.md +279 -0
- package/random.md +7 -7
- package/regex.gr +5 -5
- package/runtime/compare.gr +178 -0
- package/runtime/compare.md +6 -0
- package/runtime/equal.gr +1 -2
- package/runtime/numbers.gr +331 -86
- package/runtime/numbers.md +24 -0
- package/set.gr +1 -2
- package/set.md +1 -1
- package/string.gr +97 -15
- package/string.md +65 -1
- package/sys/file.gr +3 -3
- package/sys/file.md +3 -3
- package/sys/process.gr +3 -3
- package/sys/process.md +3 -3
- package/sys/random.gr +2 -2
- package/sys/random.md +4 -4
- package/sys/time.gr +2 -2
- package/sys/time.md +2 -2
package/buffer.gr
CHANGED
|
@@ -83,21 +83,21 @@ let checkIsIndexInBounds = (i, len, buf) => {
|
|
|
83
83
|
let addInt8help = (value, buffer) => {
|
|
84
84
|
autogrow(_8BIT_LEN, buffer)
|
|
85
85
|
let index = buffer.len
|
|
86
|
-
buffer.len
|
|
86
|
+
buffer.len += _8BIT_LEN
|
|
87
87
|
Bytes.setInt8(index, value, buffer.data)
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
let addInt16help = (value, buffer) => {
|
|
91
91
|
autogrow(_16BIT_LEN, buffer)
|
|
92
92
|
let index = buffer.len
|
|
93
|
-
buffer.len
|
|
93
|
+
buffer.len += _16BIT_LEN
|
|
94
94
|
Bytes.setInt16(index, value, buffer.data)
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
let addInt32help = (value, buffer) => {
|
|
98
98
|
autogrow(_32BIT_LEN, buffer)
|
|
99
99
|
let index = buffer.len
|
|
100
|
-
buffer.len
|
|
100
|
+
buffer.len += _32BIT_LEN
|
|
101
101
|
Bytes.setInt32(index, value, buffer.data)
|
|
102
102
|
}
|
|
103
103
|
|
|
@@ -255,7 +255,7 @@ export let addBytes = (bytes, buffer) => {
|
|
|
255
255
|
let dst = WasmI32.fromGrain(buffer.data)
|
|
256
256
|
appendBytes(0n, off, len, src, dst)
|
|
257
257
|
|
|
258
|
-
buffer.len
|
|
258
|
+
buffer.len += bytelen
|
|
259
259
|
}
|
|
260
260
|
|
|
261
261
|
/**
|
|
@@ -278,7 +278,7 @@ export let addString = (string, buffer) => {
|
|
|
278
278
|
let dst = WasmI32.fromGrain(buffer.data)
|
|
279
279
|
appendBytes(0n, off, len, src, dst)
|
|
280
280
|
|
|
281
|
-
buffer.len
|
|
281
|
+
buffer.len += bytelen
|
|
282
282
|
}
|
|
283
283
|
|
|
284
284
|
/**
|
|
@@ -318,7 +318,7 @@ export let addStringSlice = (start: Number, end, string, buffer) => {
|
|
|
318
318
|
let dst = WasmI32.fromGrain(buffer.data)
|
|
319
319
|
appendBytes(srcOff, dstOff, coerceNumberToWasmI32(bytelen), src, dst)
|
|
320
320
|
|
|
321
|
-
buffer.len
|
|
321
|
+
buffer.len += bytelen
|
|
322
322
|
}
|
|
323
323
|
|
|
324
324
|
/**
|
|
@@ -339,32 +339,34 @@ export let addBytesSlice =
|
|
|
339
339
|
bytes: Bytes,
|
|
340
340
|
buffer: Buffer,
|
|
341
341
|
) => {
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
342
|
+
if (length != 0) {
|
|
343
|
+
let (-) = WasmI32.sub
|
|
344
|
+
let (<) = WasmI32.ltS
|
|
345
|
+
let (>) = WasmI32.gtS
|
|
346
|
+
let (>=) = WasmI32.geS
|
|
347
|
+
|
|
348
|
+
// bounds check start
|
|
349
|
+
let bytelen = WasmI32.load(WasmI32.fromGrain(bytes), 4n)
|
|
350
|
+
let srcOff = coerceNumberToWasmI32(start)
|
|
351
|
+
if (srcOff < 0n || srcOff >= bytelen) {
|
|
352
|
+
throw Exception.IndexOutOfBounds
|
|
353
|
+
}
|
|
353
354
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
355
|
+
// bounds check length
|
|
356
|
+
let len = coerceNumberToWasmI32(length)
|
|
357
|
+
if (len < 0n || len > bytelen - srcOff) {
|
|
358
|
+
throw Exception.IndexOutOfBounds
|
|
359
|
+
}
|
|
359
360
|
|
|
360
|
-
|
|
361
|
+
autogrow(length, buffer)
|
|
361
362
|
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
363
|
+
let dstOff = coerceNumberToWasmI32(buffer.len)
|
|
364
|
+
let src = WasmI32.fromGrain(bytes)
|
|
365
|
+
let dst = WasmI32.fromGrain(buffer.data)
|
|
366
|
+
appendBytes(srcOff, dstOff, len, src, dst)
|
|
366
367
|
|
|
367
|
-
|
|
368
|
+
buffer.len += length
|
|
369
|
+
}
|
|
368
370
|
}
|
|
369
371
|
|
|
370
372
|
/**
|
|
@@ -588,7 +590,7 @@ export let setFloat32 = (index, value, buffer) => {
|
|
|
588
590
|
export let addFloat32 = (value, buffer) => {
|
|
589
591
|
autogrow(_32BIT_LEN, buffer)
|
|
590
592
|
let index = buffer.len
|
|
591
|
-
buffer.len
|
|
593
|
+
buffer.len += _32BIT_LEN
|
|
592
594
|
setFloat32(index, value, buffer)
|
|
593
595
|
}
|
|
594
596
|
|
|
@@ -631,7 +633,7 @@ export let setInt64 = (index, value, buffer) => {
|
|
|
631
633
|
export let addInt64 = (value, buffer) => {
|
|
632
634
|
autogrow(_64BIT_LEN, buffer)
|
|
633
635
|
let index = buffer.len
|
|
634
|
-
buffer.len
|
|
636
|
+
buffer.len += _64BIT_LEN
|
|
635
637
|
setInt64(index, value, buffer)
|
|
636
638
|
}
|
|
637
639
|
|
|
@@ -674,6 +676,6 @@ export let setFloat64 = (index, value, buffer) => {
|
|
|
674
676
|
export let addFloat64 = (value, buffer) => {
|
|
675
677
|
autogrow(_64BIT_LEN, buffer)
|
|
676
678
|
let index = buffer.len
|
|
677
|
-
buffer.len
|
|
679
|
+
buffer.len += _64BIT_LEN
|
|
678
680
|
setFloat64(index, value, buffer)
|
|
679
681
|
}
|
package/buffer.md
CHANGED
|
@@ -309,7 +309,7 @@ Parameters:
|
|
|
309
309
|
<tr><th>version</th><th>changes</th></tr>
|
|
310
310
|
</thead>
|
|
311
311
|
<tbody>
|
|
312
|
-
<tr><td><code>
|
|
312
|
+
<tr><td><code>0.5.0</code></td><td>Now takes the end offset instead of length</td></tr>
|
|
313
313
|
</tbody>
|
|
314
314
|
</table>
|
|
315
315
|
</details>
|
package/bytes.md
CHANGED
package/exception.gr
CHANGED
|
@@ -1,11 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Exception: Utilities for working with the Exception type.
|
|
3
|
+
*
|
|
4
|
+
* The Exception type represents an error that has occured during computation.
|
|
5
|
+
*
|
|
6
|
+
* @example import Exception from "exception"
|
|
7
|
+
*
|
|
8
|
+
* @since 0.3.0
|
|
9
|
+
*/
|
|
10
|
+
|
|
1
11
|
import WasmI32 from "runtime/unsafe/wasmi32"
|
|
2
12
|
import Memory from "runtime/unsafe/memory"
|
|
3
13
|
import Exception from "runtime/exception"
|
|
4
14
|
|
|
15
|
+
/**
|
|
16
|
+
* @section Values: Functions included in the Exception module.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Registers an exception printer. When an exception is thrown, all registered
|
|
21
|
+
* printers are called in order from the most recently registered printer to
|
|
22
|
+
* the least recently registered printer. The first `Some` value returned is
|
|
23
|
+
* used as the exception's string value.
|
|
24
|
+
*
|
|
25
|
+
* @param printer: The exception printer to register
|
|
26
|
+
* @since v0.3.0
|
|
27
|
+
*/
|
|
5
28
|
@disableGC
|
|
6
|
-
export let rec registerPrinter = (
|
|
29
|
+
export let rec registerPrinter = (printer: Exception -> Option<String>) => {
|
|
30
|
+
// This function _must_ be @disableGC because the printer list uses
|
|
31
|
+
// unsafe types. Not really a memory leak as this list is never collected
|
|
32
|
+
|
|
7
33
|
// no need to increment refcount on f; we just don't decRef it at the end of the function
|
|
8
|
-
Exception.printers = WasmI32.fromGrain((
|
|
34
|
+
Exception.printers = WasmI32.fromGrain((printer, Exception.printers))
|
|
9
35
|
Memory.decRef(WasmI32.fromGrain(registerPrinter))
|
|
10
36
|
void
|
|
11
37
|
}
|
package/exception.md
CHANGED
|
@@ -1,6 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Exception
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Utilities for working with the Exception type.
|
|
6
|
+
|
|
7
|
+
The Exception type represents an error that has occured during computation.
|
|
8
|
+
|
|
9
|
+
<details disabled>
|
|
10
|
+
<summary tabindex="-1">Added in <code>0.3.0</code></summary>
|
|
11
|
+
No other changes yet.
|
|
12
|
+
</details>
|
|
13
|
+
|
|
14
|
+
```grain
|
|
15
|
+
import Exception from "exception"
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Values
|
|
19
|
+
|
|
20
|
+
Functions included in the Exception module.
|
|
21
|
+
|
|
1
22
|
### Exception.**registerPrinter**
|
|
2
23
|
|
|
24
|
+
<details disabled>
|
|
25
|
+
<summary tabindex="-1">Added in <code>0.3.0</code></summary>
|
|
26
|
+
No other changes yet.
|
|
27
|
+
</details>
|
|
28
|
+
|
|
3
29
|
```grain
|
|
4
30
|
registerPrinter : (Exception -> Option<String>) -> Void
|
|
5
31
|
```
|
|
6
32
|
|
|
33
|
+
Registers an exception printer. When an exception is thrown, all registered
|
|
34
|
+
printers are called in order from the most recently registered printer to
|
|
35
|
+
the least recently registered printer. The first `Some` value returned is
|
|
36
|
+
used as the exception's string value.
|
|
37
|
+
|
|
38
|
+
Parameters:
|
|
39
|
+
|
|
40
|
+
|param|type|description|
|
|
41
|
+
|-----|----|-----------|
|
|
42
|
+
|`printer`|`Exception -> Option<String>`|The exception printer to register|
|
|
43
|
+
|
package/float32.gr
CHANGED
|
@@ -13,6 +13,56 @@ import {
|
|
|
13
13
|
coerceFloat32ToNumber as toNumber,
|
|
14
14
|
} from "runtime/numbers"
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* @section Constants: Float32 constant values.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Infinity represented as a Float32 value.
|
|
22
|
+
*
|
|
23
|
+
* @since v0.4.0
|
|
24
|
+
*/
|
|
25
|
+
@unsafe
|
|
26
|
+
export let infinity = {
|
|
27
|
+
let ptr = newFloat32(
|
|
28
|
+
WasmF32.reinterpretI32(0b01111111100000000000000000000000n)
|
|
29
|
+
)
|
|
30
|
+
WasmI32.toGrain(ptr): Float32
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* NaN (Not a Number) represented as a Float32 value.
|
|
35
|
+
*
|
|
36
|
+
* @since v0.4.0
|
|
37
|
+
*/
|
|
38
|
+
@unsafe
|
|
39
|
+
export let nan = {
|
|
40
|
+
let ptr = newFloat32(
|
|
41
|
+
WasmF32.reinterpretI32(0b01111111100000000000000000000001n)
|
|
42
|
+
)
|
|
43
|
+
WasmI32.toGrain(ptr): Float32
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Pi represented as a Float32 value.
|
|
48
|
+
*
|
|
49
|
+
* @since v0.5.2
|
|
50
|
+
*/
|
|
51
|
+
export let pi = 3.1415927f
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Tau represented as a Float32 value.
|
|
55
|
+
*
|
|
56
|
+
* @since v0.5.2
|
|
57
|
+
*/
|
|
58
|
+
export let tau = 6.2831853f
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Euler's number represented as a Float32 value.
|
|
62
|
+
*
|
|
63
|
+
* @since v0.5.2
|
|
64
|
+
*/
|
|
65
|
+
export let e = 2.7182817f
|
|
16
66
|
/**
|
|
17
67
|
* @section Conversions: Functions for converting between Numbers and the Float32 type.
|
|
18
68
|
*/
|
|
@@ -176,33 +226,3 @@ export let gte = (x: Float32, y: Float32) => {
|
|
|
176
226
|
let yv = WasmF32.load(WasmI32.fromGrain(y), 8n)
|
|
177
227
|
WasmF32.ge(xv, yv)
|
|
178
228
|
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* @section Constants: Float32 constant values.
|
|
182
|
-
*/
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Infinity represented as a Float32 value.
|
|
186
|
-
*
|
|
187
|
-
* @since v0.4.0
|
|
188
|
-
*/
|
|
189
|
-
@unsafe
|
|
190
|
-
export let infinity = {
|
|
191
|
-
let ptr = newFloat32(
|
|
192
|
-
WasmF32.reinterpretI32(0b01111111100000000000000000000000n)
|
|
193
|
-
)
|
|
194
|
-
WasmI32.toGrain(ptr): Float32
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* NaN (Not a Number) represented as a Float32 value.
|
|
199
|
-
*
|
|
200
|
-
* @since v0.4.0
|
|
201
|
-
*/
|
|
202
|
-
@unsafe
|
|
203
|
-
export let nan = {
|
|
204
|
-
let ptr = newFloat32(
|
|
205
|
-
WasmF32.reinterpretI32(0b01111111100000000000000000000001n)
|
|
206
|
-
)
|
|
207
|
-
WasmI32.toGrain(ptr): Float32
|
|
208
|
-
}
|
package/float32.md
CHANGED
|
@@ -13,6 +13,75 @@ No other changes yet.
|
|
|
13
13
|
import Float32 from "float32"
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
+
## Constants
|
|
17
|
+
|
|
18
|
+
Float32 constant values.
|
|
19
|
+
|
|
20
|
+
### Float32.**infinity**
|
|
21
|
+
|
|
22
|
+
<details disabled>
|
|
23
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
24
|
+
No other changes yet.
|
|
25
|
+
</details>
|
|
26
|
+
|
|
27
|
+
```grain
|
|
28
|
+
infinity : Float32
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Infinity represented as a Float32 value.
|
|
32
|
+
|
|
33
|
+
### Float32.**nan**
|
|
34
|
+
|
|
35
|
+
<details disabled>
|
|
36
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
37
|
+
No other changes yet.
|
|
38
|
+
</details>
|
|
39
|
+
|
|
40
|
+
```grain
|
|
41
|
+
nan : Float32
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
NaN (Not a Number) represented as a Float32 value.
|
|
45
|
+
|
|
46
|
+
### Float32.**pi**
|
|
47
|
+
|
|
48
|
+
<details disabled>
|
|
49
|
+
<summary tabindex="-1">Added in <code>0.5.2</code></summary>
|
|
50
|
+
No other changes yet.
|
|
51
|
+
</details>
|
|
52
|
+
|
|
53
|
+
```grain
|
|
54
|
+
pi : Float32
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Pi represented as a Float32 value.
|
|
58
|
+
|
|
59
|
+
### Float32.**tau**
|
|
60
|
+
|
|
61
|
+
<details disabled>
|
|
62
|
+
<summary tabindex="-1">Added in <code>0.5.2</code></summary>
|
|
63
|
+
No other changes yet.
|
|
64
|
+
</details>
|
|
65
|
+
|
|
66
|
+
```grain
|
|
67
|
+
tau : Float32
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Tau represented as a Float32 value.
|
|
71
|
+
|
|
72
|
+
### Float32.**e**
|
|
73
|
+
|
|
74
|
+
<details disabled>
|
|
75
|
+
<summary tabindex="-1">Added in <code>0.5.2</code></summary>
|
|
76
|
+
No other changes yet.
|
|
77
|
+
</details>
|
|
78
|
+
|
|
79
|
+
```grain
|
|
80
|
+
e : Float32
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Euler's number represented as a Float32 value.
|
|
84
|
+
|
|
16
85
|
## Conversions
|
|
17
86
|
|
|
18
87
|
Functions for converting between Numbers and the Float32 type.
|
|
@@ -283,33 +352,3 @@ Returns:
|
|
|
283
352
|
|----|-----------|
|
|
284
353
|
|`Bool`|`true` if the first value is greater than or equal to the second value or `false` otherwise|
|
|
285
354
|
|
|
286
|
-
## Constants
|
|
287
|
-
|
|
288
|
-
Float32 constant values.
|
|
289
|
-
|
|
290
|
-
### Float32.**infinity**
|
|
291
|
-
|
|
292
|
-
<details disabled>
|
|
293
|
-
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
294
|
-
No other changes yet.
|
|
295
|
-
</details>
|
|
296
|
-
|
|
297
|
-
```grain
|
|
298
|
-
infinity : Float32
|
|
299
|
-
```
|
|
300
|
-
|
|
301
|
-
Infinity represented as a Float32 value.
|
|
302
|
-
|
|
303
|
-
### Float32.**nan**
|
|
304
|
-
|
|
305
|
-
<details disabled>
|
|
306
|
-
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
307
|
-
No other changes yet.
|
|
308
|
-
</details>
|
|
309
|
-
|
|
310
|
-
```grain
|
|
311
|
-
nan : Float32
|
|
312
|
-
```
|
|
313
|
-
|
|
314
|
-
NaN (Not a Number) represented as a Float32 value.
|
|
315
|
-
|
package/float64.gr
CHANGED
|
@@ -13,6 +13,61 @@ import {
|
|
|
13
13
|
coerceFloat64ToNumber as toNumber,
|
|
14
14
|
} from "runtime/numbers"
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* @section Constants: Float64 constant values.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Infinity represented as a Float64 value.
|
|
22
|
+
*
|
|
23
|
+
* @since v0.4.0
|
|
24
|
+
*/
|
|
25
|
+
@unsafe
|
|
26
|
+
export let infinity = {
|
|
27
|
+
let ptr = newFloat64(
|
|
28
|
+
WasmF64.reinterpretI64(
|
|
29
|
+
0b0111111111110000000000000000000000000000000000000000000000000000N
|
|
30
|
+
)
|
|
31
|
+
)
|
|
32
|
+
WasmI32.toGrain(ptr): Float64
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* NaN (Not a Number) represented as a Float64 value.
|
|
37
|
+
*
|
|
38
|
+
* @since v0.4.0
|
|
39
|
+
*/
|
|
40
|
+
@unsafe
|
|
41
|
+
export let nan = {
|
|
42
|
+
let ptr = newFloat64(
|
|
43
|
+
WasmF64.reinterpretI64(
|
|
44
|
+
0b0111111111110000000000000000000000000000000000000000000000000001N
|
|
45
|
+
)
|
|
46
|
+
)
|
|
47
|
+
WasmI32.toGrain(ptr): Float64
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Pi represented as a Float64 value.
|
|
52
|
+
*
|
|
53
|
+
* @since v0.5.2
|
|
54
|
+
*/
|
|
55
|
+
export let pi = 3.141592653589793d
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Tau represented as a Float64 value.
|
|
59
|
+
*
|
|
60
|
+
* @since v0.5.2
|
|
61
|
+
*/
|
|
62
|
+
export let tau = 6.283185307179586d
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Euler's number represented as a Float64 value.
|
|
66
|
+
*
|
|
67
|
+
* @since v0.5.2
|
|
68
|
+
*/
|
|
69
|
+
export let e = 2.718281828459045d
|
|
70
|
+
|
|
16
71
|
/**
|
|
17
72
|
* @section Conversions: Functions for converting between Numbers and the Float64 type.
|
|
18
73
|
*/
|
|
@@ -176,37 +231,3 @@ export let gte = (x: Float64, y: Float64) => {
|
|
|
176
231
|
let yv = WasmF64.load(WasmI32.fromGrain(y), 8n)
|
|
177
232
|
WasmF64.ge(xv, yv)
|
|
178
233
|
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* @section Constants: Float64 constant values.
|
|
182
|
-
*/
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Infinity represented as a Float64 value.
|
|
186
|
-
*
|
|
187
|
-
* @since v0.4.0
|
|
188
|
-
*/
|
|
189
|
-
@unsafe
|
|
190
|
-
export let infinity = {
|
|
191
|
-
let ptr = newFloat64(
|
|
192
|
-
WasmF64.reinterpretI64(
|
|
193
|
-
0b0111111111110000000000000000000000000000000000000000000000000000N
|
|
194
|
-
)
|
|
195
|
-
)
|
|
196
|
-
WasmI32.toGrain(ptr): Float64
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* NaN (Not a Number) represented as a Float64 value.
|
|
201
|
-
*
|
|
202
|
-
* @since v0.4.0
|
|
203
|
-
*/
|
|
204
|
-
@unsafe
|
|
205
|
-
export let nan = {
|
|
206
|
-
let ptr = newFloat64(
|
|
207
|
-
WasmF64.reinterpretI64(
|
|
208
|
-
0b0111111111110000000000000000000000000000000000000000000000000001N
|
|
209
|
-
)
|
|
210
|
-
)
|
|
211
|
-
WasmI32.toGrain(ptr): Float64
|
|
212
|
-
}
|
package/float64.md
CHANGED
|
@@ -13,6 +13,75 @@ No other changes yet.
|
|
|
13
13
|
import Float64 from "float64"
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
+
## Constants
|
|
17
|
+
|
|
18
|
+
Float64 constant values.
|
|
19
|
+
|
|
20
|
+
### Float64.**infinity**
|
|
21
|
+
|
|
22
|
+
<details disabled>
|
|
23
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
24
|
+
No other changes yet.
|
|
25
|
+
</details>
|
|
26
|
+
|
|
27
|
+
```grain
|
|
28
|
+
infinity : Float64
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Infinity represented as a Float64 value.
|
|
32
|
+
|
|
33
|
+
### Float64.**nan**
|
|
34
|
+
|
|
35
|
+
<details disabled>
|
|
36
|
+
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
37
|
+
No other changes yet.
|
|
38
|
+
</details>
|
|
39
|
+
|
|
40
|
+
```grain
|
|
41
|
+
nan : Float64
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
NaN (Not a Number) represented as a Float64 value.
|
|
45
|
+
|
|
46
|
+
### Float64.**pi**
|
|
47
|
+
|
|
48
|
+
<details disabled>
|
|
49
|
+
<summary tabindex="-1">Added in <code>0.5.2</code></summary>
|
|
50
|
+
No other changes yet.
|
|
51
|
+
</details>
|
|
52
|
+
|
|
53
|
+
```grain
|
|
54
|
+
pi : Float64
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Pi represented as a Float64 value.
|
|
58
|
+
|
|
59
|
+
### Float64.**tau**
|
|
60
|
+
|
|
61
|
+
<details disabled>
|
|
62
|
+
<summary tabindex="-1">Added in <code>0.5.2</code></summary>
|
|
63
|
+
No other changes yet.
|
|
64
|
+
</details>
|
|
65
|
+
|
|
66
|
+
```grain
|
|
67
|
+
tau : Float64
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Tau represented as a Float64 value.
|
|
71
|
+
|
|
72
|
+
### Float64.**e**
|
|
73
|
+
|
|
74
|
+
<details disabled>
|
|
75
|
+
<summary tabindex="-1">Added in <code>0.5.2</code></summary>
|
|
76
|
+
No other changes yet.
|
|
77
|
+
</details>
|
|
78
|
+
|
|
79
|
+
```grain
|
|
80
|
+
e : Float64
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Euler's number represented as a Float64 value.
|
|
84
|
+
|
|
16
85
|
## Conversions
|
|
17
86
|
|
|
18
87
|
Functions for converting between Numbers and the Float64 type.
|
|
@@ -283,33 +352,3 @@ Returns:
|
|
|
283
352
|
|----|-----------|
|
|
284
353
|
|`Bool`|`true` if the first value is greater than or equal to the second value or `false` otherwise|
|
|
285
354
|
|
|
286
|
-
## Constants
|
|
287
|
-
|
|
288
|
-
Float64 constant values.
|
|
289
|
-
|
|
290
|
-
### Float64.**infinity**
|
|
291
|
-
|
|
292
|
-
<details disabled>
|
|
293
|
-
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
294
|
-
No other changes yet.
|
|
295
|
-
</details>
|
|
296
|
-
|
|
297
|
-
```grain
|
|
298
|
-
infinity : Float64
|
|
299
|
-
```
|
|
300
|
-
|
|
301
|
-
Infinity represented as a Float64 value.
|
|
302
|
-
|
|
303
|
-
### Float64.**nan**
|
|
304
|
-
|
|
305
|
-
<details disabled>
|
|
306
|
-
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
307
|
-
No other changes yet.
|
|
308
|
-
</details>
|
|
309
|
-
|
|
310
|
-
```grain
|
|
311
|
-
nan : Float64
|
|
312
|
-
```
|
|
313
|
-
|
|
314
|
-
NaN (Not a Number) represented as a Float64 value.
|
|
315
|
-
|