@grain/stdlib 0.5.13 → 0.6.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 +193 -0
- package/LICENSE +1 -1
- package/README.md +25 -2
- package/array.gr +1512 -199
- package/array.md +2032 -94
- package/bigint.gr +239 -140
- package/bigint.md +450 -106
- package/buffer.gr +595 -102
- package/buffer.md +903 -145
- package/bytes.gr +401 -110
- package/bytes.md +551 -63
- package/char.gr +228 -49
- package/char.md +373 -7
- package/exception.gr +26 -12
- package/exception.md +29 -5
- package/float32.gr +130 -109
- package/float32.md +185 -57
- package/float64.gr +112 -99
- package/float64.md +185 -57
- package/hash.gr +47 -37
- package/hash.md +21 -3
- package/int16.gr +430 -0
- package/int16.md +618 -0
- package/int32.gr +200 -269
- package/int32.md +254 -289
- package/int64.gr +142 -225
- package/int64.md +254 -289
- package/int8.gr +511 -0
- package/int8.md +786 -0
- package/json.gr +2084 -0
- package/json.md +608 -0
- package/list.gr +120 -68
- package/list.md +125 -80
- package/map.gr +560 -57
- package/map.md +672 -56
- package/marshal.gr +239 -227
- package/marshal.md +36 -4
- package/number.gr +626 -676
- package/number.md +738 -153
- package/option.gr +33 -35
- package/option.md +58 -42
- package/package.json +2 -2
- package/path.gr +148 -187
- package/path.md +47 -96
- package/pervasives.gr +75 -416
- package/pervasives.md +85 -180
- package/priorityqueue.gr +433 -74
- package/priorityqueue.md +422 -54
- package/queue.gr +362 -80
- package/queue.md +433 -38
- package/random.gr +67 -75
- package/random.md +68 -40
- package/range.gr +135 -63
- package/range.md +198 -43
- package/rational.gr +284 -0
- package/rational.md +545 -0
- package/regex.gr +933 -1066
- package/regex.md +59 -60
- package/result.gr +23 -25
- package/result.md +54 -39
- package/runtime/atof/common.gr +78 -82
- package/runtime/atof/common.md +22 -10
- package/runtime/atof/decimal.gr +102 -127
- package/runtime/atof/decimal.md +28 -7
- package/runtime/atof/lemire.gr +56 -71
- package/runtime/atof/lemire.md +9 -1
- package/runtime/atof/parse.gr +83 -110
- package/runtime/atof/parse.md +12 -2
- package/runtime/atof/slow.gr +28 -35
- package/runtime/atof/slow.md +9 -1
- package/runtime/atof/table.gr +19 -18
- package/runtime/atof/table.md +10 -2
- package/runtime/atoi/parse.gr +153 -136
- package/runtime/atoi/parse.md +50 -1
- package/runtime/bigint.gr +410 -517
- package/runtime/bigint.md +71 -57
- package/runtime/compare.gr +176 -85
- package/runtime/compare.md +31 -1
- package/runtime/dataStructures.gr +144 -32
- package/runtime/dataStructures.md +267 -31
- package/runtime/debugPrint.gr +34 -15
- package/runtime/debugPrint.md +37 -5
- package/runtime/equal.gr +53 -52
- package/runtime/equal.md +30 -1
- package/runtime/exception.gr +38 -47
- package/runtime/exception.md +10 -8
- package/runtime/gc.gr +23 -152
- package/runtime/gc.md +13 -17
- package/runtime/malloc.gr +31 -31
- package/runtime/malloc.md +11 -3
- package/runtime/numberUtils.gr +191 -172
- package/runtime/numberUtils.md +17 -9
- package/runtime/numbers.gr +1695 -1021
- package/runtime/numbers.md +1098 -134
- package/runtime/string.gr +540 -242
- package/runtime/string.md +76 -6
- package/runtime/unsafe/constants.gr +30 -13
- package/runtime/unsafe/constants.md +80 -0
- package/runtime/unsafe/conv.gr +55 -28
- package/runtime/unsafe/conv.md +41 -9
- package/runtime/unsafe/memory.gr +10 -30
- package/runtime/unsafe/memory.md +15 -19
- package/runtime/unsafe/tags.gr +37 -21
- package/runtime/unsafe/tags.md +88 -8
- package/runtime/unsafe/wasmf32.gr +30 -36
- package/runtime/unsafe/wasmf32.md +64 -56
- package/runtime/unsafe/wasmf64.gr +30 -36
- package/runtime/unsafe/wasmf64.md +64 -56
- package/runtime/unsafe/wasmi32.gr +49 -66
- package/runtime/unsafe/wasmi32.md +102 -94
- package/runtime/unsafe/wasmi64.gr +52 -79
- package/runtime/unsafe/wasmi64.md +108 -100
- package/runtime/utils/printing.gr +13 -15
- package/runtime/utils/printing.md +11 -3
- package/runtime/wasi.gr +294 -295
- package/runtime/wasi.md +62 -42
- package/set.gr +574 -64
- package/set.md +634 -54
- package/stack.gr +181 -64
- package/stack.md +271 -42
- package/string.gr +453 -533
- package/string.md +241 -151
- package/uint16.gr +369 -0
- package/uint16.md +585 -0
- package/uint32.gr +470 -0
- package/uint32.md +737 -0
- package/uint64.gr +471 -0
- package/uint64.md +737 -0
- package/uint8.gr +369 -0
- package/uint8.md +585 -0
- package/uri.gr +1093 -0
- package/uri.md +477 -0
- package/{sys → wasi}/file.gr +914 -500
- package/{sys → wasi}/file.md +454 -50
- package/wasi/process.gr +292 -0
- package/{sys → wasi}/process.md +164 -6
- package/wasi/random.gr +77 -0
- package/wasi/random.md +80 -0
- package/{sys → wasi}/time.gr +15 -22
- package/{sys → wasi}/time.md +5 -5
- package/immutablearray.gr +0 -929
- package/immutablearray.md +0 -1038
- package/immutablemap.gr +0 -493
- package/immutablemap.md +0 -479
- package/immutablepriorityqueue.gr +0 -360
- package/immutablepriorityqueue.md +0 -291
- package/immutableset.gr +0 -498
- package/immutableset.md +0 -449
- package/runtime/debug.gr +0 -2
- package/runtime/debug.md +0 -6
- package/runtime/unsafe/errors.gr +0 -36
- package/runtime/unsafe/errors.md +0 -204
- package/sys/process.gr +0 -254
- package/sys/random.gr +0 -79
- package/sys/random.md +0 -66
package/runtime/numbers.md
CHANGED
|
@@ -1,356 +1,1320 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Numbers
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
## Values
|
|
6
|
+
|
|
7
|
+
Functions and constants included in the Numbers module.
|
|
8
|
+
|
|
9
|
+
### Numbers.**tagSimple**
|
|
10
|
+
|
|
11
|
+
```grain
|
|
12
|
+
tagSimple : (x: WasmI32) => WasmI32
|
|
13
|
+
```
|
|
14
|
+
|
|
1
15
|
### Numbers.**isBoxedNumber**
|
|
2
16
|
|
|
3
17
|
```grain
|
|
4
|
-
isBoxedNumber : WasmI32
|
|
18
|
+
isBoxedNumber : (x: WasmI32) => Bool
|
|
5
19
|
```
|
|
6
20
|
|
|
7
21
|
### Numbers.**isFloat**
|
|
8
22
|
|
|
9
23
|
```grain
|
|
10
|
-
isFloat : WasmI32
|
|
24
|
+
isFloat : (x: WasmI32) => Bool
|
|
11
25
|
```
|
|
12
26
|
|
|
13
27
|
### Numbers.**isInteger**
|
|
14
28
|
|
|
15
29
|
```grain
|
|
16
|
-
isInteger : WasmI32
|
|
30
|
+
isInteger : (x: WasmI32) => Bool
|
|
17
31
|
```
|
|
18
32
|
|
|
19
33
|
### Numbers.**isRational**
|
|
20
34
|
|
|
21
35
|
```grain
|
|
22
|
-
isRational : WasmI32
|
|
36
|
+
isRational : (x: WasmI32) => Bool
|
|
23
37
|
```
|
|
24
38
|
|
|
25
39
|
### Numbers.**isNaN**
|
|
26
40
|
|
|
27
41
|
```grain
|
|
28
|
-
isNaN : WasmI32
|
|
42
|
+
isNaN : (x: WasmI32) => Bool
|
|
29
43
|
```
|
|
30
44
|
|
|
31
45
|
### Numbers.**isNumber**
|
|
32
46
|
|
|
33
47
|
```grain
|
|
34
|
-
isNumber : WasmI32
|
|
48
|
+
isNumber : (x: WasmI32) => Bool
|
|
35
49
|
```
|
|
36
50
|
|
|
37
51
|
### Numbers.**reducedInteger**
|
|
38
52
|
|
|
39
53
|
```grain
|
|
40
|
-
reducedInteger : WasmI64
|
|
54
|
+
reducedInteger : (x: WasmI64) => WasmI32
|
|
41
55
|
```
|
|
42
56
|
|
|
43
|
-
### Numbers.**
|
|
57
|
+
### Numbers.**reducedUnsignedInteger**
|
|
44
58
|
|
|
45
59
|
```grain
|
|
46
|
-
|
|
60
|
+
reducedUnsignedInteger : (x: WasmI64) => WasmI32
|
|
47
61
|
```
|
|
48
62
|
|
|
49
|
-
### Numbers.**
|
|
63
|
+
### Numbers.**boxedNumberTag**
|
|
50
64
|
|
|
51
65
|
```grain
|
|
52
|
-
|
|
66
|
+
boxedNumberTag : (xptr: WasmI32) => WasmI32
|
|
53
67
|
```
|
|
54
68
|
|
|
55
69
|
### Numbers.**boxedInt64Number**
|
|
56
70
|
|
|
57
71
|
```grain
|
|
58
|
-
boxedInt64Number : WasmI32
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
### Numbers.**boxedFloat32Number**
|
|
62
|
-
|
|
63
|
-
```grain
|
|
64
|
-
boxedFloat32Number : WasmI32 -> WasmF32
|
|
72
|
+
boxedInt64Number : (xptr: WasmI32) => WasmI64
|
|
65
73
|
```
|
|
66
74
|
|
|
67
75
|
### Numbers.**boxedFloat64Number**
|
|
68
76
|
|
|
69
77
|
```grain
|
|
70
|
-
boxedFloat64Number : WasmI32
|
|
78
|
+
boxedFloat64Number : (xptr: WasmI32) => WasmF64
|
|
71
79
|
```
|
|
72
80
|
|
|
73
81
|
### Numbers.**boxedRationalNumerator**
|
|
74
82
|
|
|
75
83
|
```grain
|
|
76
|
-
boxedRationalNumerator : WasmI32
|
|
84
|
+
boxedRationalNumerator : (xptr: WasmI32) => WasmI32
|
|
77
85
|
```
|
|
78
86
|
|
|
79
87
|
### Numbers.**boxedRationalDenominator**
|
|
80
88
|
|
|
81
89
|
```grain
|
|
82
|
-
boxedRationalDenominator : WasmI32
|
|
90
|
+
boxedRationalDenominator : (xptr: WasmI32) => WasmI32
|
|
83
91
|
```
|
|
84
92
|
|
|
85
93
|
### Numbers.**coerceNumberToWasmF32**
|
|
86
94
|
|
|
87
95
|
```grain
|
|
88
|
-
coerceNumberToWasmF32 : Number
|
|
96
|
+
coerceNumberToWasmF32 : (x: Number) => WasmF32
|
|
89
97
|
```
|
|
90
98
|
|
|
91
99
|
### Numbers.**coerceNumberToWasmF64**
|
|
92
100
|
|
|
93
101
|
```grain
|
|
94
|
-
coerceNumberToWasmF64 : Number
|
|
102
|
+
coerceNumberToWasmF64 : (x: Number) => WasmF64
|
|
95
103
|
```
|
|
96
104
|
|
|
97
105
|
### Numbers.**coerceNumberToWasmI64**
|
|
98
106
|
|
|
99
107
|
```grain
|
|
100
|
-
coerceNumberToWasmI64 : Number
|
|
108
|
+
coerceNumberToWasmI64 : (x: Number) => WasmI64
|
|
101
109
|
```
|
|
102
110
|
|
|
103
111
|
### Numbers.**coerceNumberToWasmI32**
|
|
104
112
|
|
|
105
113
|
```grain
|
|
106
|
-
coerceNumberToWasmI32 : Number
|
|
114
|
+
coerceNumberToWasmI32 : (x: Number) => WasmI32
|
|
107
115
|
```
|
|
108
116
|
|
|
109
|
-
### Numbers.**
|
|
117
|
+
### Numbers.**coerceNumberToUnsignedWasmI64**
|
|
110
118
|
|
|
111
119
|
```grain
|
|
112
|
-
|
|
120
|
+
coerceNumberToUnsignedWasmI64 : (x: Number) => WasmI64
|
|
113
121
|
```
|
|
114
122
|
|
|
115
|
-
### Numbers.**
|
|
123
|
+
### Numbers.**coerceNumberToUnsignedWasmI32**
|
|
116
124
|
|
|
117
125
|
```grain
|
|
118
|
-
|
|
126
|
+
coerceNumberToUnsignedWasmI32 : (x: Number) => WasmI32
|
|
119
127
|
```
|
|
120
128
|
|
|
121
|
-
### Numbers.**
|
|
129
|
+
### Numbers.**numberEqual**
|
|
122
130
|
|
|
123
131
|
```grain
|
|
124
|
-
|
|
132
|
+
numberEqual : (x: WasmI32, y: WasmI32) => Bool
|
|
125
133
|
```
|
|
126
134
|
|
|
127
|
-
### Numbers.**
|
|
135
|
+
### Numbers.**addSubRational**
|
|
128
136
|
|
|
129
137
|
```grain
|
|
130
|
-
|
|
138
|
+
addSubRational :
|
|
139
|
+
(x: WasmI32, y: WasmI32, isSub: Bool, keepRational: Bool) => WasmI32
|
|
131
140
|
```
|
|
132
141
|
|
|
133
|
-
### Numbers.**
|
|
142
|
+
### Numbers.**timesDivideRational**
|
|
134
143
|
|
|
135
144
|
```grain
|
|
136
|
-
|
|
145
|
+
timesDivideRational :
|
|
146
|
+
(x: WasmI32, y: WasmI32, isDivide: Bool, keepRational: Bool) => WasmI32
|
|
137
147
|
```
|
|
138
148
|
|
|
139
|
-
### Numbers.**
|
|
149
|
+
### Numbers.**rationalsEqual**
|
|
140
150
|
|
|
141
151
|
```grain
|
|
142
|
-
|
|
152
|
+
rationalsEqual : (x: WasmI32, y: WasmI32) => Bool
|
|
143
153
|
```
|
|
144
154
|
|
|
145
|
-
### Numbers.**
|
|
155
|
+
### Numbers.**cmpRationals**
|
|
146
156
|
|
|
147
157
|
```grain
|
|
148
|
-
|
|
158
|
+
cmpRationals : (x: WasmI32, y: WasmI32) => WasmI32
|
|
149
159
|
```
|
|
150
160
|
|
|
151
|
-
### Numbers.**
|
|
161
|
+
### Numbers.**rationalNumerator**
|
|
162
|
+
|
|
163
|
+
<details disabled>
|
|
164
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
165
|
+
No other changes yet.
|
|
166
|
+
</details>
|
|
152
167
|
|
|
153
168
|
```grain
|
|
154
|
-
|
|
169
|
+
rationalNumerator : (x: Rational) => Number
|
|
155
170
|
```
|
|
156
171
|
|
|
157
|
-
|
|
172
|
+
Finds the numerator of the rational number.
|
|
158
173
|
|
|
159
|
-
|
|
160
|
-
lnot : Number -> Number
|
|
161
|
-
```
|
|
174
|
+
Parameters:
|
|
162
175
|
|
|
163
|
-
|
|
176
|
+
|param|type|description|
|
|
177
|
+
|-----|----|-----------|
|
|
178
|
+
|`x`|`Rational`|The rational number to inspect|
|
|
164
179
|
|
|
165
|
-
|
|
166
|
-
(<<) : (Number, Number) -> Number
|
|
167
|
-
```
|
|
180
|
+
Returns:
|
|
168
181
|
|
|
169
|
-
|
|
182
|
+
|type|description|
|
|
183
|
+
|----|-----------|
|
|
184
|
+
|`Number`|The numerator of the rational number|
|
|
170
185
|
|
|
171
|
-
|
|
172
|
-
(>>>) : (Number, Number) -> Number
|
|
173
|
-
```
|
|
186
|
+
### Numbers.**rationalDenominator**
|
|
174
187
|
|
|
175
|
-
|
|
188
|
+
<details disabled>
|
|
189
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
190
|
+
No other changes yet.
|
|
191
|
+
</details>
|
|
176
192
|
|
|
177
193
|
```grain
|
|
178
|
-
|
|
194
|
+
rationalDenominator : (x: Rational) => Number
|
|
179
195
|
```
|
|
180
196
|
|
|
181
|
-
|
|
197
|
+
Finds the denominator of the rational number.
|
|
182
198
|
|
|
183
|
-
|
|
184
|
-
(|) : (Number, Number) -> Number
|
|
185
|
-
```
|
|
199
|
+
Parameters:
|
|
186
200
|
|
|
187
|
-
|
|
201
|
+
|param|type|description|
|
|
202
|
+
|-----|----|-----------|
|
|
203
|
+
|`x`|`Rational`|The rational number to inspect|
|
|
188
204
|
|
|
189
|
-
|
|
190
|
-
(^) : (Number, Number) -> Number
|
|
191
|
-
```
|
|
205
|
+
Returns:
|
|
192
206
|
|
|
193
|
-
|
|
207
|
+
|type|description|
|
|
208
|
+
|----|-----------|
|
|
209
|
+
|`Number`|The denominator of the rational number|
|
|
210
|
+
|
|
211
|
+
### Numbers.**cmp**
|
|
194
212
|
|
|
195
213
|
```grain
|
|
196
|
-
|
|
214
|
+
cmp : (x: WasmI32, y: WasmI32) => WasmI32
|
|
197
215
|
```
|
|
198
216
|
|
|
199
|
-
### Numbers.**
|
|
217
|
+
### Numbers.**(<)**
|
|
218
|
+
|
|
219
|
+
<details disabled>
|
|
220
|
+
<summary tabindex="-1">Added in <code>0.1.0</code></summary>
|
|
221
|
+
No other changes yet.
|
|
222
|
+
</details>
|
|
200
223
|
|
|
201
224
|
```grain
|
|
202
|
-
|
|
225
|
+
(<) : (num1: Number, num2: Number) => Bool
|
|
203
226
|
```
|
|
204
227
|
|
|
205
|
-
|
|
228
|
+
Checks if the first operand is less than the second operand.
|
|
206
229
|
|
|
207
|
-
|
|
208
|
-
coerceNumberToInt64 : Number -> Int64
|
|
209
|
-
```
|
|
230
|
+
Parameters:
|
|
210
231
|
|
|
211
|
-
|
|
232
|
+
|param|type|description|
|
|
233
|
+
|-----|----|-----------|
|
|
234
|
+
|`num1`|`Number`|The first operand|
|
|
235
|
+
|`num2`|`Number`|The second operand|
|
|
212
236
|
|
|
213
|
-
|
|
214
|
-
coerceNumberToBigInt : Number -> BigInt
|
|
215
|
-
```
|
|
237
|
+
Returns:
|
|
216
238
|
|
|
217
|
-
|
|
239
|
+
|type|description|
|
|
240
|
+
|----|-----------|
|
|
241
|
+
|`Bool`|`true` if the first operand is less than the second operand or `false` otherwise|
|
|
218
242
|
|
|
219
|
-
|
|
220
|
-
coerceNumberToRational : Number -> Rational
|
|
221
|
-
```
|
|
243
|
+
### Numbers.**(>)**
|
|
222
244
|
|
|
223
|
-
|
|
245
|
+
<details disabled>
|
|
246
|
+
<summary tabindex="-1">Added in <code>0.1.0</code></summary>
|
|
247
|
+
No other changes yet.
|
|
248
|
+
</details>
|
|
224
249
|
|
|
225
250
|
```grain
|
|
226
|
-
|
|
251
|
+
(>) : (num1: Number, num2: Number) => Bool
|
|
227
252
|
```
|
|
228
253
|
|
|
229
|
-
|
|
254
|
+
Checks if the first operand is greater than the second operand.
|
|
230
255
|
|
|
231
|
-
|
|
232
|
-
coerceNumberToFloat64 : Number -> Float64
|
|
233
|
-
```
|
|
256
|
+
Parameters:
|
|
234
257
|
|
|
235
|
-
|
|
258
|
+
|param|type|description|
|
|
259
|
+
|-----|----|-----------|
|
|
260
|
+
|`num1`|`Number`|The first operand|
|
|
261
|
+
|`num2`|`Number`|The second operand|
|
|
236
262
|
|
|
237
|
-
|
|
238
|
-
coerceInt32ToNumber : Int32 -> Number
|
|
239
|
-
```
|
|
263
|
+
Returns:
|
|
240
264
|
|
|
241
|
-
|
|
265
|
+
|type|description|
|
|
266
|
+
|----|-----------|
|
|
267
|
+
|`Bool`|`true` if the first operand is greater than the second operand or `false` otherwise|
|
|
242
268
|
|
|
243
|
-
|
|
244
|
-
coerceInt64ToNumber : Int64 -> Number
|
|
245
|
-
```
|
|
269
|
+
### Numbers.**(<=)**
|
|
246
270
|
|
|
247
|
-
|
|
271
|
+
<details disabled>
|
|
272
|
+
<summary tabindex="-1">Added in <code>0.1.0</code></summary>
|
|
273
|
+
No other changes yet.
|
|
274
|
+
</details>
|
|
248
275
|
|
|
249
276
|
```grain
|
|
250
|
-
|
|
277
|
+
(<=) : (num1: Number, num2: Number) => Bool
|
|
251
278
|
```
|
|
252
279
|
|
|
253
|
-
|
|
280
|
+
Checks if the first operand is less than or equal to the second operand.
|
|
254
281
|
|
|
255
|
-
|
|
256
|
-
coerceRationalToNumber : Rational -> Number
|
|
257
|
-
```
|
|
282
|
+
Parameters:
|
|
258
283
|
|
|
259
|
-
|
|
284
|
+
|param|type|description|
|
|
285
|
+
|-----|----|-----------|
|
|
286
|
+
|`num1`|`Number`|The first operand|
|
|
287
|
+
|`num2`|`Number`|The second operand|
|
|
260
288
|
|
|
261
|
-
|
|
262
|
-
coerceFloat32ToNumber : Float32 -> Number
|
|
263
|
-
```
|
|
289
|
+
Returns:
|
|
264
290
|
|
|
265
|
-
|
|
291
|
+
|type|description|
|
|
292
|
+
|----|-----------|
|
|
293
|
+
|`Bool`|`true` if the first operand is less than or equal to the second operand or `false` otherwise|
|
|
266
294
|
|
|
267
|
-
|
|
268
|
-
coerceFloat64ToNumber : Float64 -> Number
|
|
269
|
-
```
|
|
295
|
+
### Numbers.**(>=)**
|
|
270
296
|
|
|
271
|
-
|
|
297
|
+
<details disabled>
|
|
298
|
+
<summary tabindex="-1">Added in <code>0.1.0</code></summary>
|
|
299
|
+
No other changes yet.
|
|
300
|
+
</details>
|
|
272
301
|
|
|
273
302
|
```grain
|
|
274
|
-
|
|
303
|
+
(>=) : (num1: Number, num2: Number) => Bool
|
|
275
304
|
```
|
|
276
305
|
|
|
277
|
-
|
|
306
|
+
Checks if the first operand is greater than or equal to the second operand.
|
|
307
|
+
|
|
308
|
+
Parameters:
|
|
309
|
+
|
|
310
|
+
|param|type|description|
|
|
311
|
+
|-----|----|-----------|
|
|
312
|
+
|`num1`|`Number`|The first operand|
|
|
313
|
+
|`num2`|`Number`|The second operand|
|
|
314
|
+
|
|
315
|
+
Returns:
|
|
316
|
+
|
|
317
|
+
|type|description|
|
|
318
|
+
|----|-----------|
|
|
319
|
+
|`Bool`|`true` if the first operand is greater than or equal to the second operand or `false` otherwise|
|
|
320
|
+
|
|
321
|
+
### Numbers.**compare**
|
|
278
322
|
|
|
279
323
|
```grain
|
|
280
|
-
|
|
324
|
+
compare : (x: Number, y: Number) => Number
|
|
281
325
|
```
|
|
282
326
|
|
|
283
|
-
### Numbers.**
|
|
327
|
+
### Numbers.**numberEq**
|
|
284
328
|
|
|
285
329
|
```grain
|
|
286
|
-
|
|
330
|
+
numberEq : (x: Number, y: Number) => Bool
|
|
287
331
|
```
|
|
288
332
|
|
|
289
|
-
### Numbers.**
|
|
333
|
+
### Numbers.**lnot**
|
|
334
|
+
|
|
335
|
+
<details disabled>
|
|
336
|
+
<summary tabindex="-1">Added in <code>0.2.0</code></summary>
|
|
337
|
+
No other changes yet.
|
|
338
|
+
</details>
|
|
290
339
|
|
|
291
340
|
```grain
|
|
292
|
-
|
|
341
|
+
lnot : (value: Number) => Number
|
|
293
342
|
```
|
|
294
343
|
|
|
295
|
-
|
|
344
|
+
Computes the bitwise NOT of the operand.
|
|
345
|
+
|
|
346
|
+
Parameters:
|
|
347
|
+
|
|
348
|
+
|param|type|description|
|
|
349
|
+
|-----|----|-----------|
|
|
350
|
+
|`value`|`Number`|The operand|
|
|
351
|
+
|
|
352
|
+
Returns:
|
|
353
|
+
|
|
354
|
+
|type|description|
|
|
355
|
+
|----|-----------|
|
|
356
|
+
|`Number`|Containing the inverted bits of the operand|
|
|
357
|
+
|
|
358
|
+
### Numbers.**(<<)**
|
|
359
|
+
|
|
360
|
+
<details>
|
|
361
|
+
<summary>Added in <code>0.3.0</code></summary>
|
|
362
|
+
<table>
|
|
363
|
+
<thead>
|
|
364
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
365
|
+
</thead>
|
|
366
|
+
<tbody>
|
|
367
|
+
<tr><td><code>0.2.0</code></td><td>Originally named `lsl`</td></tr>
|
|
368
|
+
<tr><td><code>0.3.0</code></td><td>Renamed to `<<`</td></tr>
|
|
369
|
+
</tbody>
|
|
370
|
+
</table>
|
|
371
|
+
</details>
|
|
296
372
|
|
|
297
373
|
```grain
|
|
298
|
-
(
|
|
374
|
+
(<<) : (value: Number, amount: Number) => Number
|
|
299
375
|
```
|
|
300
376
|
|
|
301
|
-
|
|
377
|
+
Shifts the bits of the value left by the given number of bits.
|
|
378
|
+
|
|
379
|
+
Parameters:
|
|
380
|
+
|
|
381
|
+
|param|type|description|
|
|
382
|
+
|-----|----|-----------|
|
|
383
|
+
|`value`|`Number`|The value to shift|
|
|
384
|
+
|`amount`|`Number`|The number of bits to shift by|
|
|
385
|
+
|
|
386
|
+
Returns:
|
|
387
|
+
|
|
388
|
+
|type|description|
|
|
389
|
+
|----|-----------|
|
|
390
|
+
|`Number`|The shifted value|
|
|
391
|
+
|
|
392
|
+
### Numbers.**(>>>)**
|
|
393
|
+
|
|
394
|
+
<details>
|
|
395
|
+
<summary>Added in <code>0.3.0</code></summary>
|
|
396
|
+
<table>
|
|
397
|
+
<thead>
|
|
398
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
399
|
+
</thead>
|
|
400
|
+
<tbody>
|
|
401
|
+
<tr><td><code>0.2.0</code></td><td>Originally named `lsr`</td></tr>
|
|
402
|
+
<tr><td><code>0.3.0</code></td><td>Renamed to `>>>`</td></tr>
|
|
403
|
+
</tbody>
|
|
404
|
+
</table>
|
|
405
|
+
</details>
|
|
302
406
|
|
|
303
407
|
```grain
|
|
304
|
-
(
|
|
408
|
+
(>>>) : (value: Number, amount: Number) => Number
|
|
305
409
|
```
|
|
306
410
|
|
|
307
|
-
|
|
411
|
+
Shifts the bits of the value right by the given number of bits, preserving the sign bit.
|
|
412
|
+
|
|
413
|
+
Parameters:
|
|
414
|
+
|
|
415
|
+
|param|type|description|
|
|
416
|
+
|-----|----|-----------|
|
|
417
|
+
|`value`|`Number`|The value to shift|
|
|
418
|
+
|`amount`|`Number`|The amount to shift by|
|
|
419
|
+
|
|
420
|
+
Returns:
|
|
421
|
+
|
|
422
|
+
|type|description|
|
|
423
|
+
|----|-----------|
|
|
424
|
+
|`Number`|The shifted value|
|
|
425
|
+
|
|
426
|
+
### Numbers.**(&)**
|
|
427
|
+
|
|
428
|
+
<details>
|
|
429
|
+
<summary>Added in <code>0.3.0</code></summary>
|
|
430
|
+
<table>
|
|
431
|
+
<thead>
|
|
432
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
433
|
+
</thead>
|
|
434
|
+
<tbody>
|
|
435
|
+
<tr><td><code>0.2.0</code></td><td>Originally named `land`</td></tr>
|
|
436
|
+
<tr><td><code>0.3.0</code></td><td>Renamed to `&`</td></tr>
|
|
437
|
+
</tbody>
|
|
438
|
+
</table>
|
|
439
|
+
</details>
|
|
308
440
|
|
|
309
441
|
```grain
|
|
310
|
-
(
|
|
442
|
+
(&) : (value1: Number, value2: Number) => Number
|
|
311
443
|
```
|
|
312
444
|
|
|
313
|
-
|
|
445
|
+
Computes the bitwise AND (`&`) on the given operands.
|
|
446
|
+
|
|
447
|
+
Parameters:
|
|
448
|
+
|
|
449
|
+
|param|type|description|
|
|
450
|
+
|-----|----|-----------|
|
|
451
|
+
|`value1`|`Number`|The first operand|
|
|
452
|
+
|`value2`|`Number`|The second operand|
|
|
453
|
+
|
|
454
|
+
Returns:
|
|
455
|
+
|
|
456
|
+
|type|description|
|
|
457
|
+
|----|-----------|
|
|
458
|
+
|`Number`|Containing a `1` in each bit position for which the corresponding bits of both operands are `1`|
|
|
459
|
+
|
|
460
|
+
### Numbers.**(|)**
|
|
461
|
+
|
|
462
|
+
<details>
|
|
463
|
+
<summary>Added in <code>0.3.0</code></summary>
|
|
464
|
+
<table>
|
|
465
|
+
<thead>
|
|
466
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
467
|
+
</thead>
|
|
468
|
+
<tbody>
|
|
469
|
+
<tr><td><code>0.2.0</code></td><td>Originally named `lor`</td></tr>
|
|
470
|
+
<tr><td><code>0.3.0</code></td><td>Renamed to `|`</td></tr>
|
|
471
|
+
</tbody>
|
|
472
|
+
</table>
|
|
473
|
+
</details>
|
|
314
474
|
|
|
315
475
|
```grain
|
|
316
|
-
|
|
476
|
+
(|) : (value1: Number, value2: Number) => Number
|
|
317
477
|
```
|
|
318
478
|
|
|
319
|
-
|
|
479
|
+
Computes the bitwise OR (`|`) on the given operands.
|
|
480
|
+
|
|
481
|
+
Parameters:
|
|
482
|
+
|
|
483
|
+
|param|type|description|
|
|
484
|
+
|-----|----|-----------|
|
|
485
|
+
|`value1`|`Number`|The first operand|
|
|
486
|
+
|`value2`|`Number`|The second operand|
|
|
487
|
+
|
|
488
|
+
Returns:
|
|
489
|
+
|
|
490
|
+
|type|description|
|
|
491
|
+
|----|-----------|
|
|
492
|
+
|`Number`|Containing a `1` in each bit position for which the corresponding bits of either or both operands are `1`|
|
|
493
|
+
|
|
494
|
+
### Numbers.**(^)**
|
|
495
|
+
|
|
496
|
+
<details>
|
|
497
|
+
<summary>Added in <code>0.3.0</code></summary>
|
|
498
|
+
<table>
|
|
499
|
+
<thead>
|
|
500
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
501
|
+
</thead>
|
|
502
|
+
<tbody>
|
|
503
|
+
<tr><td><code>0.1.0</code></td><td>The `^` operator was originally an alias of `unbox`</td></tr>
|
|
504
|
+
<tr><td><code>0.2.0</code></td><td>Originally named `lxor`</td></tr>
|
|
505
|
+
<tr><td><code>0.3.0</code></td><td>Renamed to `^`</td></tr>
|
|
506
|
+
</tbody>
|
|
507
|
+
</table>
|
|
508
|
+
</details>
|
|
320
509
|
|
|
321
510
|
```grain
|
|
322
|
-
|
|
511
|
+
(^) : (value1: Number, value2: Number) => Number
|
|
323
512
|
```
|
|
324
513
|
|
|
325
|
-
|
|
514
|
+
Computes the bitwise XOR (`^`) on the given operands.
|
|
515
|
+
|
|
516
|
+
Parameters:
|
|
517
|
+
|
|
518
|
+
|param|type|description|
|
|
519
|
+
|-----|----|-----------|
|
|
520
|
+
|`value1`|`Number`|The first operand|
|
|
521
|
+
|`value2`|`Number`|The second operand|
|
|
522
|
+
|
|
523
|
+
Returns:
|
|
524
|
+
|
|
525
|
+
|type|description|
|
|
526
|
+
|----|-----------|
|
|
527
|
+
|`Number`|Containing a `1` in each bit position for which the corresponding bits of either but not both operands are `1`|
|
|
528
|
+
|
|
529
|
+
### Numbers.**(>>)**
|
|
530
|
+
|
|
531
|
+
<details>
|
|
532
|
+
<summary>Added in <code>0.3.0</code></summary>
|
|
533
|
+
<table>
|
|
534
|
+
<thead>
|
|
535
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
536
|
+
</thead>
|
|
537
|
+
<tbody>
|
|
538
|
+
<tr><td><code>0.2.0</code></td><td>Originally named `asr`</td></tr>
|
|
539
|
+
<tr><td><code>0.3.0</code></td><td>Renamed to `>>`</td></tr>
|
|
540
|
+
</tbody>
|
|
541
|
+
</table>
|
|
542
|
+
</details>
|
|
326
543
|
|
|
327
544
|
```grain
|
|
328
|
-
|
|
545
|
+
(>>) : (value: Number, amount: Number) => Number
|
|
329
546
|
```
|
|
330
547
|
|
|
331
|
-
|
|
548
|
+
Shifts the bits of the value right by the given number of bits.
|
|
549
|
+
|
|
550
|
+
Parameters:
|
|
551
|
+
|
|
552
|
+
|param|type|description|
|
|
553
|
+
|-----|----|-----------|
|
|
554
|
+
|`value`|`Number`|The value to shift|
|
|
555
|
+
|`amount`|`Number`|The amount to shift by|
|
|
556
|
+
|
|
557
|
+
Returns:
|
|
558
|
+
|
|
559
|
+
|type|description|
|
|
560
|
+
|----|-----------|
|
|
561
|
+
|`Number`|The shifted value|
|
|
562
|
+
|
|
563
|
+
### Numbers.**coerceNumberToInt8**
|
|
332
564
|
|
|
333
565
|
<details disabled>
|
|
334
|
-
<summary tabindex="-1">Added in <code>0.
|
|
566
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
335
567
|
No other changes yet.
|
|
336
568
|
</details>
|
|
337
569
|
|
|
338
570
|
```grain
|
|
339
|
-
|
|
571
|
+
coerceNumberToInt8 : (number: Number) => Int8
|
|
340
572
|
```
|
|
341
573
|
|
|
342
|
-
|
|
574
|
+
Converts a Number to an Int8.
|
|
343
575
|
|
|
344
576
|
Parameters:
|
|
345
577
|
|
|
346
578
|
|param|type|description|
|
|
347
579
|
|-----|----|-----------|
|
|
348
|
-
|`
|
|
349
|
-
|`n`|`WasmI32`|The Integer exponent|
|
|
580
|
+
|`number`|`Number`|The value to convert|
|
|
350
581
|
|
|
351
582
|
Returns:
|
|
352
583
|
|
|
353
584
|
|type|description|
|
|
354
585
|
|----|-----------|
|
|
355
|
-
|`
|
|
586
|
+
|`Int8`|The Number represented as an Int8|
|
|
587
|
+
|
|
588
|
+
### Numbers.**coerceNumberToInt16**
|
|
589
|
+
|
|
590
|
+
<details disabled>
|
|
591
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
592
|
+
No other changes yet.
|
|
593
|
+
</details>
|
|
594
|
+
|
|
595
|
+
```grain
|
|
596
|
+
coerceNumberToInt16 : (number: Number) => Int16
|
|
597
|
+
```
|
|
598
|
+
|
|
599
|
+
Converts a Number to an Int16.
|
|
600
|
+
|
|
601
|
+
Parameters:
|
|
602
|
+
|
|
603
|
+
|param|type|description|
|
|
604
|
+
|-----|----|-----------|
|
|
605
|
+
|`number`|`Number`|The value to convert|
|
|
606
|
+
|
|
607
|
+
Returns:
|
|
608
|
+
|
|
609
|
+
|type|description|
|
|
610
|
+
|----|-----------|
|
|
611
|
+
|`Int16`|The Number represented as an Int16|
|
|
612
|
+
|
|
613
|
+
### Numbers.**coerceNumberToUint8**
|
|
614
|
+
|
|
615
|
+
<details disabled>
|
|
616
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
617
|
+
No other changes yet.
|
|
618
|
+
</details>
|
|
619
|
+
|
|
620
|
+
```grain
|
|
621
|
+
coerceNumberToUint8 : (number: Number) => Uint8
|
|
622
|
+
```
|
|
623
|
+
|
|
624
|
+
Converts a Number to a Uint8.
|
|
625
|
+
|
|
626
|
+
Parameters:
|
|
627
|
+
|
|
628
|
+
|param|type|description|
|
|
629
|
+
|-----|----|-----------|
|
|
630
|
+
|`number`|`Number`|The value to convert|
|
|
631
|
+
|
|
632
|
+
Returns:
|
|
633
|
+
|
|
634
|
+
|type|description|
|
|
635
|
+
|----|-----------|
|
|
636
|
+
|`Uint8`|The Number represented as a Uint8|
|
|
637
|
+
|
|
638
|
+
### Numbers.**coerceNumberToUint16**
|
|
639
|
+
|
|
640
|
+
<details disabled>
|
|
641
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
642
|
+
No other changes yet.
|
|
643
|
+
</details>
|
|
644
|
+
|
|
645
|
+
```grain
|
|
646
|
+
coerceNumberToUint16 : (number: Number) => Uint16
|
|
647
|
+
```
|
|
648
|
+
|
|
649
|
+
Converts a Number to a Uint16.
|
|
650
|
+
|
|
651
|
+
Parameters:
|
|
652
|
+
|
|
653
|
+
|param|type|description|
|
|
654
|
+
|-----|----|-----------|
|
|
655
|
+
|`number`|`Number`|The value to convert|
|
|
656
|
+
|
|
657
|
+
Returns:
|
|
658
|
+
|
|
659
|
+
|type|description|
|
|
660
|
+
|----|-----------|
|
|
661
|
+
|`Uint16`|The Number represented as a Uint16|
|
|
662
|
+
|
|
663
|
+
### Numbers.**coerceNumberToInt32**
|
|
664
|
+
|
|
665
|
+
<details disabled>
|
|
666
|
+
<summary tabindex="-1">Added in <code>0.2.0</code></summary>
|
|
667
|
+
No other changes yet.
|
|
668
|
+
</details>
|
|
669
|
+
|
|
670
|
+
```grain
|
|
671
|
+
coerceNumberToInt32 : (number: Number) => Int32
|
|
672
|
+
```
|
|
673
|
+
|
|
674
|
+
Converts a Number to an Int32.
|
|
675
|
+
|
|
676
|
+
Parameters:
|
|
677
|
+
|
|
678
|
+
|param|type|description|
|
|
679
|
+
|-----|----|-----------|
|
|
680
|
+
|`number`|`Number`|The value to convert|
|
|
681
|
+
|
|
682
|
+
Returns:
|
|
683
|
+
|
|
684
|
+
|type|description|
|
|
685
|
+
|----|-----------|
|
|
686
|
+
|`Int32`|The Number represented as an Int32|
|
|
687
|
+
|
|
688
|
+
### Numbers.**coerceNumberToInt64**
|
|
689
|
+
|
|
690
|
+
<details disabled>
|
|
691
|
+
<summary tabindex="-1">Added in <code>0.2.0</code></summary>
|
|
692
|
+
No other changes yet.
|
|
693
|
+
</details>
|
|
694
|
+
|
|
695
|
+
```grain
|
|
696
|
+
coerceNumberToInt64 : (number: Number) => Int64
|
|
697
|
+
```
|
|
698
|
+
|
|
699
|
+
Converts a Number to an Int64.
|
|
700
|
+
|
|
701
|
+
Parameters:
|
|
702
|
+
|
|
703
|
+
|param|type|description|
|
|
704
|
+
|-----|----|-----------|
|
|
705
|
+
|`number`|`Number`|The value to convert|
|
|
706
|
+
|
|
707
|
+
Returns:
|
|
708
|
+
|
|
709
|
+
|type|description|
|
|
710
|
+
|----|-----------|
|
|
711
|
+
|`Int64`|The Number represented as an Int64|
|
|
712
|
+
|
|
713
|
+
### Numbers.**coerceNumberToBigInt**
|
|
714
|
+
|
|
715
|
+
<details disabled>
|
|
716
|
+
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
717
|
+
No other changes yet.
|
|
718
|
+
</details>
|
|
719
|
+
|
|
720
|
+
```grain
|
|
721
|
+
coerceNumberToBigInt : (number: Number) => BigInt
|
|
722
|
+
```
|
|
723
|
+
|
|
724
|
+
Converts a Number to a BigInt.
|
|
725
|
+
|
|
726
|
+
Parameters:
|
|
727
|
+
|
|
728
|
+
|param|type|description|
|
|
729
|
+
|-----|----|-----------|
|
|
730
|
+
|`number`|`Number`|The value to convert|
|
|
731
|
+
|
|
732
|
+
Returns:
|
|
733
|
+
|
|
734
|
+
|type|description|
|
|
735
|
+
|----|-----------|
|
|
736
|
+
|`BigInt`|The Number represented as a BigInt|
|
|
737
|
+
|
|
738
|
+
### Numbers.**coerceNumberToRational**
|
|
739
|
+
|
|
740
|
+
<details disabled>
|
|
741
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
742
|
+
No other changes yet.
|
|
743
|
+
</details>
|
|
744
|
+
|
|
745
|
+
```grain
|
|
746
|
+
coerceNumberToRational : (number: Number) => Rational
|
|
747
|
+
```
|
|
748
|
+
|
|
749
|
+
Converts a Number to a Rational.
|
|
750
|
+
|
|
751
|
+
Parameters:
|
|
752
|
+
|
|
753
|
+
|param|type|description|
|
|
754
|
+
|-----|----|-----------|
|
|
755
|
+
|`number`|`Number`|The value to convert|
|
|
756
|
+
|
|
757
|
+
Returns:
|
|
758
|
+
|
|
759
|
+
|type|description|
|
|
760
|
+
|----|-----------|
|
|
761
|
+
|`Rational`|The Number represented as a Rational|
|
|
762
|
+
|
|
763
|
+
### Numbers.**coerceNumberToFloat32**
|
|
764
|
+
|
|
765
|
+
<details disabled>
|
|
766
|
+
<summary tabindex="-1">Added in <code>0.2.0</code></summary>
|
|
767
|
+
No other changes yet.
|
|
768
|
+
</details>
|
|
769
|
+
|
|
770
|
+
```grain
|
|
771
|
+
coerceNumberToFloat32 : (number: Number) => Float32
|
|
772
|
+
```
|
|
773
|
+
|
|
774
|
+
Converts a Number to a Float32.
|
|
775
|
+
|
|
776
|
+
Parameters:
|
|
777
|
+
|
|
778
|
+
|param|type|description|
|
|
779
|
+
|-----|----|-----------|
|
|
780
|
+
|`number`|`Number`|The value to convert|
|
|
781
|
+
|
|
782
|
+
Returns:
|
|
783
|
+
|
|
784
|
+
|type|description|
|
|
785
|
+
|----|-----------|
|
|
786
|
+
|`Float32`|The Number represented as a Float32|
|
|
787
|
+
|
|
788
|
+
### Numbers.**coerceNumberToFloat64**
|
|
789
|
+
|
|
790
|
+
<details disabled>
|
|
791
|
+
<summary tabindex="-1">Added in <code>0.2.0</code></summary>
|
|
792
|
+
No other changes yet.
|
|
793
|
+
</details>
|
|
794
|
+
|
|
795
|
+
```grain
|
|
796
|
+
coerceNumberToFloat64 : (number: Number) => Float64
|
|
797
|
+
```
|
|
798
|
+
|
|
799
|
+
Converts a Number to a Float64.
|
|
800
|
+
|
|
801
|
+
Parameters:
|
|
802
|
+
|
|
803
|
+
|param|type|description|
|
|
804
|
+
|-----|----|-----------|
|
|
805
|
+
|`number`|`Number`|The value to convert|
|
|
806
|
+
|
|
807
|
+
Returns:
|
|
808
|
+
|
|
809
|
+
|type|description|
|
|
810
|
+
|----|-----------|
|
|
811
|
+
|`Float64`|The Number represented as a Float64|
|
|
812
|
+
|
|
813
|
+
### Numbers.**coerceInt8ToNumber**
|
|
814
|
+
|
|
815
|
+
<details disabled>
|
|
816
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
817
|
+
No other changes yet.
|
|
818
|
+
</details>
|
|
819
|
+
|
|
820
|
+
```grain
|
|
821
|
+
coerceInt8ToNumber : (value: Int8) => Number
|
|
822
|
+
```
|
|
823
|
+
|
|
824
|
+
Converts an Int8 to a Number.
|
|
825
|
+
|
|
826
|
+
Parameters:
|
|
827
|
+
|
|
828
|
+
|param|type|description|
|
|
829
|
+
|-----|----|-----------|
|
|
830
|
+
|`value`|`Int8`|The value to convert|
|
|
831
|
+
|
|
832
|
+
Returns:
|
|
833
|
+
|
|
834
|
+
|type|description|
|
|
835
|
+
|----|-----------|
|
|
836
|
+
|`Number`|The Int8 represented as a Number|
|
|
837
|
+
|
|
838
|
+
### Numbers.**coerceInt16ToNumber**
|
|
839
|
+
|
|
840
|
+
<details disabled>
|
|
841
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
842
|
+
No other changes yet.
|
|
843
|
+
</details>
|
|
844
|
+
|
|
845
|
+
```grain
|
|
846
|
+
coerceInt16ToNumber : (value: Int16) => Number
|
|
847
|
+
```
|
|
848
|
+
|
|
849
|
+
Converts an Int16 to a Number.
|
|
850
|
+
|
|
851
|
+
Parameters:
|
|
852
|
+
|
|
853
|
+
|param|type|description|
|
|
854
|
+
|-----|----|-----------|
|
|
855
|
+
|`value`|`Int16`|The value to convert|
|
|
856
|
+
|
|
857
|
+
Returns:
|
|
858
|
+
|
|
859
|
+
|type|description|
|
|
860
|
+
|----|-----------|
|
|
861
|
+
|`Number`|The Int16 represented as a Number|
|
|
862
|
+
|
|
863
|
+
### Numbers.**coerceUint8ToNumber**
|
|
864
|
+
|
|
865
|
+
<details disabled>
|
|
866
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
867
|
+
No other changes yet.
|
|
868
|
+
</details>
|
|
869
|
+
|
|
870
|
+
```grain
|
|
871
|
+
coerceUint8ToNumber : (value: Uint8) => Number
|
|
872
|
+
```
|
|
873
|
+
|
|
874
|
+
Converts a Uint8 to a Number.
|
|
875
|
+
|
|
876
|
+
Parameters:
|
|
877
|
+
|
|
878
|
+
|param|type|description|
|
|
879
|
+
|-----|----|-----------|
|
|
880
|
+
|`value`|`Uint8`|The value to convert|
|
|
881
|
+
|
|
882
|
+
Returns:
|
|
883
|
+
|
|
884
|
+
|type|description|
|
|
885
|
+
|----|-----------|
|
|
886
|
+
|`Number`|The Uint8 represented as a Number|
|
|
887
|
+
|
|
888
|
+
### Numbers.**coerceUint16ToNumber**
|
|
889
|
+
|
|
890
|
+
<details disabled>
|
|
891
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
892
|
+
No other changes yet.
|
|
893
|
+
</details>
|
|
894
|
+
|
|
895
|
+
```grain
|
|
896
|
+
coerceUint16ToNumber : (value: Uint16) => Number
|
|
897
|
+
```
|
|
898
|
+
|
|
899
|
+
Converts a Uint16 to a Number.
|
|
900
|
+
|
|
901
|
+
Parameters:
|
|
902
|
+
|
|
903
|
+
|param|type|description|
|
|
904
|
+
|-----|----|-----------|
|
|
905
|
+
|`value`|`Uint16`|The value to convert|
|
|
906
|
+
|
|
907
|
+
Returns:
|
|
908
|
+
|
|
909
|
+
|type|description|
|
|
910
|
+
|----|-----------|
|
|
911
|
+
|`Number`|The Uint16 represented as a Number|
|
|
912
|
+
|
|
913
|
+
### Numbers.**coerceInt32ToNumber**
|
|
914
|
+
|
|
915
|
+
<details disabled>
|
|
916
|
+
<summary tabindex="-1">Added in <code>0.2.0</code></summary>
|
|
917
|
+
No other changes yet.
|
|
918
|
+
</details>
|
|
919
|
+
|
|
920
|
+
```grain
|
|
921
|
+
coerceInt32ToNumber : (value: Int32) => Number
|
|
922
|
+
```
|
|
923
|
+
|
|
924
|
+
Converts an Int32 to a Number.
|
|
925
|
+
|
|
926
|
+
Parameters:
|
|
927
|
+
|
|
928
|
+
|param|type|description|
|
|
929
|
+
|-----|----|-----------|
|
|
930
|
+
|`value`|`Int32`|The value to convert|
|
|
931
|
+
|
|
932
|
+
Returns:
|
|
933
|
+
|
|
934
|
+
|type|description|
|
|
935
|
+
|----|-----------|
|
|
936
|
+
|`Number`|The Int32 represented as a Number|
|
|
937
|
+
|
|
938
|
+
### Numbers.**coerceInt64ToNumber**
|
|
939
|
+
|
|
940
|
+
<details disabled>
|
|
941
|
+
<summary tabindex="-1">Added in <code>0.2.0</code></summary>
|
|
942
|
+
No other changes yet.
|
|
943
|
+
</details>
|
|
944
|
+
|
|
945
|
+
```grain
|
|
946
|
+
coerceInt64ToNumber : (value: Int64) => Number
|
|
947
|
+
```
|
|
948
|
+
|
|
949
|
+
Converts an Int64 to a Number.
|
|
950
|
+
|
|
951
|
+
Parameters:
|
|
952
|
+
|
|
953
|
+
|param|type|description|
|
|
954
|
+
|-----|----|-----------|
|
|
955
|
+
|`value`|`Int64`|The value to convert|
|
|
956
|
+
|
|
957
|
+
Returns:
|
|
958
|
+
|
|
959
|
+
|type|description|
|
|
960
|
+
|----|-----------|
|
|
961
|
+
|`Number`|The Int64 represented as a Number|
|
|
962
|
+
|
|
963
|
+
### Numbers.**coerceBigIntToNumber**
|
|
964
|
+
|
|
965
|
+
<details disabled>
|
|
966
|
+
<summary tabindex="-1">Added in <code>0.5.0</code></summary>
|
|
967
|
+
No other changes yet.
|
|
968
|
+
</details>
|
|
969
|
+
|
|
970
|
+
```grain
|
|
971
|
+
coerceBigIntToNumber : (num: BigInt) => Number
|
|
972
|
+
```
|
|
973
|
+
|
|
974
|
+
Converts a BigInt to a Number.
|
|
975
|
+
|
|
976
|
+
Parameters:
|
|
977
|
+
|
|
978
|
+
|param|type|description|
|
|
979
|
+
|-----|----|-----------|
|
|
980
|
+
|`num`|`BigInt`|The value to convert|
|
|
981
|
+
|
|
982
|
+
Returns:
|
|
983
|
+
|
|
984
|
+
|type|description|
|
|
985
|
+
|----|-----------|
|
|
986
|
+
|`Number`|The BigInt represented as a Number|
|
|
987
|
+
|
|
988
|
+
### Numbers.**coerceRationalToNumber**
|
|
989
|
+
|
|
990
|
+
<details disabled>
|
|
991
|
+
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
|
|
992
|
+
No other changes yet.
|
|
993
|
+
</details>
|
|
994
|
+
|
|
995
|
+
```grain
|
|
996
|
+
coerceRationalToNumber : (rational: Rational) => Number
|
|
997
|
+
```
|
|
998
|
+
|
|
999
|
+
Converts a Rational to a Number.
|
|
1000
|
+
|
|
1001
|
+
Parameters:
|
|
1002
|
+
|
|
1003
|
+
|param|type|description|
|
|
1004
|
+
|-----|----|-----------|
|
|
1005
|
+
|`rational`|`Rational`|The value to convert|
|
|
1006
|
+
|
|
1007
|
+
Returns:
|
|
1008
|
+
|
|
1009
|
+
|type|description|
|
|
1010
|
+
|----|-----------|
|
|
1011
|
+
|`Number`|The Rational represented as a Number|
|
|
1012
|
+
|
|
1013
|
+
### Numbers.**coerceFloat32ToNumber**
|
|
1014
|
+
|
|
1015
|
+
<details disabled>
|
|
1016
|
+
<summary tabindex="-1">Added in <code>0.2.0</code></summary>
|
|
1017
|
+
No other changes yet.
|
|
1018
|
+
</details>
|
|
1019
|
+
|
|
1020
|
+
```grain
|
|
1021
|
+
coerceFloat32ToNumber : (float: Float32) => Number
|
|
1022
|
+
```
|
|
1023
|
+
|
|
1024
|
+
Converts a Float32 to a Number.
|
|
1025
|
+
|
|
1026
|
+
Parameters:
|
|
1027
|
+
|
|
1028
|
+
|param|type|description|
|
|
1029
|
+
|-----|----|-----------|
|
|
1030
|
+
|`float`|`Float32`|The value to convert|
|
|
1031
|
+
|
|
1032
|
+
Returns:
|
|
1033
|
+
|
|
1034
|
+
|type|description|
|
|
1035
|
+
|----|-----------|
|
|
1036
|
+
|`Number`|The Float32 represented as a Number|
|
|
1037
|
+
|
|
1038
|
+
### Numbers.**coerceFloat64ToNumber**
|
|
1039
|
+
|
|
1040
|
+
<details disabled>
|
|
1041
|
+
<summary tabindex="-1">Added in <code>0.2.0</code></summary>
|
|
1042
|
+
No other changes yet.
|
|
1043
|
+
</details>
|
|
1044
|
+
|
|
1045
|
+
```grain
|
|
1046
|
+
coerceFloat64ToNumber : (float: Float64) => Number
|
|
1047
|
+
```
|
|
1048
|
+
|
|
1049
|
+
Converts a Float64 to a Number.
|
|
1050
|
+
|
|
1051
|
+
Parameters:
|
|
1052
|
+
|
|
1053
|
+
|param|type|description|
|
|
1054
|
+
|-----|----|-----------|
|
|
1055
|
+
|`float`|`Float64`|The value to convert|
|
|
1056
|
+
|
|
1057
|
+
Returns:
|
|
1058
|
+
|
|
1059
|
+
|type|description|
|
|
1060
|
+
|----|-----------|
|
|
1061
|
+
|`Number`|The Float64 represented as a Number|
|
|
1062
|
+
|
|
1063
|
+
### Numbers.**convertExactToInexact**
|
|
1064
|
+
|
|
1065
|
+
```grain
|
|
1066
|
+
convertExactToInexact : (x: Number) => Number
|
|
1067
|
+
```
|
|
1068
|
+
|
|
1069
|
+
### Numbers.**convertInexactToExact**
|
|
1070
|
+
|
|
1071
|
+
```grain
|
|
1072
|
+
convertInexactToExact : (x: Number) => Number
|
|
1073
|
+
```
|
|
1074
|
+
|
|
1075
|
+
### Numbers.**(+)**
|
|
1076
|
+
|
|
1077
|
+
<details disabled>
|
|
1078
|
+
<summary tabindex="-1">Added in <code>0.1.0</code></summary>
|
|
1079
|
+
No other changes yet.
|
|
1080
|
+
</details>
|
|
1081
|
+
|
|
1082
|
+
```grain
|
|
1083
|
+
(+) : (num1: Number, num2: Number) => Number
|
|
1084
|
+
```
|
|
1085
|
+
|
|
1086
|
+
Computes the sum of its operands.
|
|
1087
|
+
|
|
1088
|
+
Parameters:
|
|
1089
|
+
|
|
1090
|
+
|param|type|description|
|
|
1091
|
+
|-----|----|-----------|
|
|
1092
|
+
|`num1`|`Number`|The first operand|
|
|
1093
|
+
|`num2`|`Number`|The second operand|
|
|
1094
|
+
|
|
1095
|
+
Returns:
|
|
1096
|
+
|
|
1097
|
+
|type|description|
|
|
1098
|
+
|----|-----------|
|
|
1099
|
+
|`Number`|The sum of the two operands|
|
|
1100
|
+
|
|
1101
|
+
### Numbers.**(-)**
|
|
1102
|
+
|
|
1103
|
+
<details disabled>
|
|
1104
|
+
<summary tabindex="-1">Added in <code>0.1.0</code></summary>
|
|
1105
|
+
No other changes yet.
|
|
1106
|
+
</details>
|
|
1107
|
+
|
|
1108
|
+
```grain
|
|
1109
|
+
(-) : (num1: Number, num2: Number) => Number
|
|
1110
|
+
```
|
|
1111
|
+
|
|
1112
|
+
Computes the difference of its operands.
|
|
1113
|
+
|
|
1114
|
+
Parameters:
|
|
1115
|
+
|
|
1116
|
+
|param|type|description|
|
|
1117
|
+
|-----|----|-----------|
|
|
1118
|
+
|`num1`|`Number`|The first operand|
|
|
1119
|
+
|`num2`|`Number`|The second operand|
|
|
1120
|
+
|
|
1121
|
+
Returns:
|
|
1122
|
+
|
|
1123
|
+
|type|description|
|
|
1124
|
+
|----|-----------|
|
|
1125
|
+
|`Number`|The difference of the two operands|
|
|
1126
|
+
|
|
1127
|
+
### Numbers.**(*)**
|
|
1128
|
+
|
|
1129
|
+
<details disabled>
|
|
1130
|
+
<summary tabindex="-1">Added in <code>0.1.0</code></summary>
|
|
1131
|
+
No other changes yet.
|
|
1132
|
+
</details>
|
|
1133
|
+
|
|
1134
|
+
```grain
|
|
1135
|
+
(*) : (num1: Number, num2: Number) => Number
|
|
1136
|
+
```
|
|
1137
|
+
|
|
1138
|
+
Computes the product of its operands.
|
|
1139
|
+
|
|
1140
|
+
Parameters:
|
|
1141
|
+
|
|
1142
|
+
|param|type|description|
|
|
1143
|
+
|-----|----|-----------|
|
|
1144
|
+
|`num1`|`Number`|The first operand|
|
|
1145
|
+
|`num2`|`Number`|The second operand|
|
|
1146
|
+
|
|
1147
|
+
Returns:
|
|
1148
|
+
|
|
1149
|
+
|type|description|
|
|
1150
|
+
|----|-----------|
|
|
1151
|
+
|`Number`|The product of the two operands|
|
|
1152
|
+
|
|
1153
|
+
### Numbers.**(/)**
|
|
1154
|
+
|
|
1155
|
+
<details disabled>
|
|
1156
|
+
<summary tabindex="-1">Added in <code>0.1.0</code></summary>
|
|
1157
|
+
No other changes yet.
|
|
1158
|
+
</details>
|
|
1159
|
+
|
|
1160
|
+
```grain
|
|
1161
|
+
(/) : (num1: Number, num2: Number) => Number
|
|
1162
|
+
```
|
|
1163
|
+
|
|
1164
|
+
Computes the quotient of its operands.
|
|
1165
|
+
|
|
1166
|
+
Parameters:
|
|
1167
|
+
|
|
1168
|
+
|param|type|description|
|
|
1169
|
+
|-----|----|-----------|
|
|
1170
|
+
|`num1`|`Number`|The first operand|
|
|
1171
|
+
|`num2`|`Number`|The second operand|
|
|
1172
|
+
|
|
1173
|
+
Returns:
|
|
1174
|
+
|
|
1175
|
+
|type|description|
|
|
1176
|
+
|----|-----------|
|
|
1177
|
+
|`Number`|The quotient of the two operands|
|
|
1178
|
+
|
|
1179
|
+
### Numbers.**(%)**
|
|
1180
|
+
|
|
1181
|
+
<details disabled>
|
|
1182
|
+
<summary tabindex="-1">Added in <code>0.1.0</code></summary>
|
|
1183
|
+
No other changes yet.
|
|
1184
|
+
</details>
|
|
1185
|
+
|
|
1186
|
+
```grain
|
|
1187
|
+
(%) : (num1: Number, num2: Number) => Number
|
|
1188
|
+
```
|
|
1189
|
+
|
|
1190
|
+
Computes the remainder of the division of the first operand by the second.
|
|
1191
|
+
The result will have the sign of the second operand.
|
|
1192
|
+
|
|
1193
|
+
Parameters:
|
|
1194
|
+
|
|
1195
|
+
|param|type|description|
|
|
1196
|
+
|-----|----|-----------|
|
|
1197
|
+
|`num1`|`Number`|The first operand|
|
|
1198
|
+
|`num2`|`Number`|The second operand|
|
|
1199
|
+
|
|
1200
|
+
Returns:
|
|
1201
|
+
|
|
1202
|
+
|type|description|
|
|
1203
|
+
|----|-----------|
|
|
1204
|
+
|`Number`|The modulus of its operands|
|
|
1205
|
+
|
|
1206
|
+
### Numbers.**incr**
|
|
1207
|
+
|
|
1208
|
+
<details disabled>
|
|
1209
|
+
<summary tabindex="-1">Added in <code>0.1.0</code></summary>
|
|
1210
|
+
No other changes yet.
|
|
1211
|
+
</details>
|
|
1212
|
+
|
|
1213
|
+
```grain
|
|
1214
|
+
incr : (value: Number) => Number
|
|
1215
|
+
```
|
|
1216
|
+
|
|
1217
|
+
Increments the value by one.
|
|
1218
|
+
|
|
1219
|
+
Parameters:
|
|
1220
|
+
|
|
1221
|
+
|param|type|description|
|
|
1222
|
+
|-----|----|-----------|
|
|
1223
|
+
|`value`|`Number`|The value to increment|
|
|
1224
|
+
|
|
1225
|
+
Returns:
|
|
1226
|
+
|
|
1227
|
+
|type|description|
|
|
1228
|
+
|----|-----------|
|
|
1229
|
+
|`Number`|The incremented value|
|
|
1230
|
+
|
|
1231
|
+
### Numbers.**decr**
|
|
1232
|
+
|
|
1233
|
+
<details disabled>
|
|
1234
|
+
<summary tabindex="-1">Added in <code>0.1.0</code></summary>
|
|
1235
|
+
No other changes yet.
|
|
1236
|
+
</details>
|
|
1237
|
+
|
|
1238
|
+
```grain
|
|
1239
|
+
decr : (value: Number) => Number
|
|
1240
|
+
```
|
|
1241
|
+
|
|
1242
|
+
Decrements the value by one.
|
|
1243
|
+
|
|
1244
|
+
Parameters:
|
|
1245
|
+
|
|
1246
|
+
|param|type|description|
|
|
1247
|
+
|-----|----|-----------|
|
|
1248
|
+
|`value`|`Number`|The value to decrement|
|
|
1249
|
+
|
|
1250
|
+
Returns:
|
|
1251
|
+
|
|
1252
|
+
|type|description|
|
|
1253
|
+
|----|-----------|
|
|
1254
|
+
|`Number`|The decremented value|
|
|
1255
|
+
|
|
1256
|
+
### Numbers.**isBigInt**
|
|
1257
|
+
|
|
1258
|
+
```grain
|
|
1259
|
+
isBigInt : (x: a) => Bool
|
|
1260
|
+
```
|
|
1261
|
+
|
|
1262
|
+
### Numbers.**scalbn**
|
|
1263
|
+
|
|
1264
|
+
<details disabled>
|
|
1265
|
+
<summary tabindex="-1">Added in <code>0.5.4</code></summary>
|
|
1266
|
+
No other changes yet.
|
|
1267
|
+
</details>
|
|
1268
|
+
|
|
1269
|
+
```grain
|
|
1270
|
+
scalbn : (x: WasmF64, n: WasmI32) => WasmF64
|
|
1271
|
+
```
|
|
1272
|
+
|
|
1273
|
+
Multiplies a floating-point number by an integral power of 2.
|
|
1274
|
+
|
|
1275
|
+
Parameters:
|
|
1276
|
+
|
|
1277
|
+
|param|type|description|
|
|
1278
|
+
|-----|----|-----------|
|
|
1279
|
+
|`x`|`WasmF64`|The floating-point value|
|
|
1280
|
+
|`n`|`WasmI32`|The Integer exponent|
|
|
1281
|
+
|
|
1282
|
+
Returns:
|
|
1283
|
+
|
|
1284
|
+
|type|description|
|
|
1285
|
+
|----|-----------|
|
|
1286
|
+
|`WasmF64`|The result of x * 2^n|
|
|
1287
|
+
|
|
1288
|
+
### Numbers.**(\*\*)**
|
|
1289
|
+
|
|
1290
|
+
<details>
|
|
1291
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
1292
|
+
<table>
|
|
1293
|
+
<thead>
|
|
1294
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
1295
|
+
</thead>
|
|
1296
|
+
<tbody>
|
|
1297
|
+
<tr><td><code>0.5.4</code></td><td>Originally existed in Number module</td></tr>
|
|
1298
|
+
</tbody>
|
|
1299
|
+
</table>
|
|
1300
|
+
</details>
|
|
1301
|
+
|
|
1302
|
+
```grain
|
|
1303
|
+
(**) : (base: Number, power: Number) => Number
|
|
1304
|
+
```
|
|
1305
|
+
|
|
1306
|
+
Computes the exponentiation of the given base and power.
|
|
1307
|
+
|
|
1308
|
+
Parameters:
|
|
1309
|
+
|
|
1310
|
+
|param|type|description|
|
|
1311
|
+
|-----|----|-----------|
|
|
1312
|
+
|`base`|`Number`|The base number|
|
|
1313
|
+
|`power`|`Number`|The exponent number|
|
|
1314
|
+
|
|
1315
|
+
Returns:
|
|
1316
|
+
|
|
1317
|
+
|type|description|
|
|
1318
|
+
|----|-----------|
|
|
1319
|
+
|`Number`|The base raised to the given power|
|
|
356
1320
|
|