@grain/stdlib 0.6.3 → 0.6.5
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 +21 -0
- package/LICENSE +1 -1
- package/array.gr +2 -0
- package/bytes.gr +38 -7
- package/float32.gr +68 -0
- package/float32.md +164 -0
- package/float64.gr +87 -16
- package/float64.md +164 -0
- package/hash.gr +2 -0
- package/int16.gr +85 -0
- package/int16.md +168 -0
- package/int32.gr +107 -0
- package/int32.md +235 -0
- package/int64.gr +107 -0
- package/int64.md +235 -0
- package/int8.gr +1 -1
- package/int8.md +1 -1
- package/map.gr +3 -2
- package/package.json +1 -1
- package/pervasives.md +10 -3
- package/runtime/malloc.gr +269 -135
- package/runtime/malloc.md +3 -10
- package/runtime/numbers.gr +181 -100
- package/runtime/string.gr +1 -0
- package/runtime/string.md +10 -3
- package/set.gr +0 -5
- package/string.gr +291 -72
- package/string.md +108 -0
- package/wasi/file.gr +5 -0
- package/wasi/process.gr +2 -1
package/float64.md
CHANGED
|
@@ -480,3 +480,167 @@ use Float64.{ (>=) }
|
|
|
480
480
|
assert -1.0d >= -1.0d
|
|
481
481
|
```
|
|
482
482
|
|
|
483
|
+
### Float64.**isNaN**
|
|
484
|
+
|
|
485
|
+
<details disabled>
|
|
486
|
+
<summary tabindex="-1">Added in <code>0.6.5</code></summary>
|
|
487
|
+
No other changes yet.
|
|
488
|
+
</details>
|
|
489
|
+
|
|
490
|
+
```grain
|
|
491
|
+
isNaN : (x: Float64) => Bool
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
Checks if the value is a float NaN value (Not A Number).
|
|
495
|
+
|
|
496
|
+
Parameters:
|
|
497
|
+
|
|
498
|
+
|param|type|description|
|
|
499
|
+
|-----|----|-----------|
|
|
500
|
+
|`x`|`Float64`|The value to check|
|
|
501
|
+
|
|
502
|
+
Returns:
|
|
503
|
+
|
|
504
|
+
|type|description|
|
|
505
|
+
|----|-----------|
|
|
506
|
+
|`Bool`|`true` if the value is NaN, otherwise `false`|
|
|
507
|
+
|
|
508
|
+
Examples:
|
|
509
|
+
|
|
510
|
+
```grain
|
|
511
|
+
Float64.isNaN(NaNd)
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
```grain
|
|
515
|
+
Float64.isNaN(Infinityd) == false
|
|
516
|
+
```
|
|
517
|
+
|
|
518
|
+
```grain
|
|
519
|
+
Float64.isNaN(-Infinityd) == false
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
```grain
|
|
523
|
+
Float64.isNaN(0.5d) == false
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
```grain
|
|
527
|
+
Float64.isNaN(1.0d) == false
|
|
528
|
+
```
|
|
529
|
+
|
|
530
|
+
### Float64.**isInfinite**
|
|
531
|
+
|
|
532
|
+
<details disabled>
|
|
533
|
+
<summary tabindex="-1">Added in <code>0.6.5</code></summary>
|
|
534
|
+
No other changes yet.
|
|
535
|
+
</details>
|
|
536
|
+
|
|
537
|
+
```grain
|
|
538
|
+
isInfinite : (x: Float64) => Bool
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
Checks if a float is infinite, that is either of positive or negative infinity.
|
|
542
|
+
|
|
543
|
+
Parameters:
|
|
544
|
+
|
|
545
|
+
|param|type|description|
|
|
546
|
+
|-----|----|-----------|
|
|
547
|
+
|`x`|`Float64`|The value to check|
|
|
548
|
+
|
|
549
|
+
Returns:
|
|
550
|
+
|
|
551
|
+
|type|description|
|
|
552
|
+
|----|-----------|
|
|
553
|
+
|`Bool`|`true` if the value is infinite or `false` otherwise|
|
|
554
|
+
|
|
555
|
+
Examples:
|
|
556
|
+
|
|
557
|
+
```grain
|
|
558
|
+
Float64.isInfinite(Infinityd)
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
```grain
|
|
562
|
+
Float64.isInfinite(-Infinityd)
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
```grain
|
|
566
|
+
Float64.isInfinite(NaNd) == false
|
|
567
|
+
```
|
|
568
|
+
|
|
569
|
+
```grain
|
|
570
|
+
Float64.isInfinite(0.5d) == false
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
```grain
|
|
574
|
+
Float64.isInfinite(1.0d) == false
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
### Float64.**abs**
|
|
578
|
+
|
|
579
|
+
<details disabled>
|
|
580
|
+
<summary tabindex="-1">Added in <code>0.6.5</code></summary>
|
|
581
|
+
No other changes yet.
|
|
582
|
+
</details>
|
|
583
|
+
|
|
584
|
+
```grain
|
|
585
|
+
abs : (x: Float64) => Float64
|
|
586
|
+
```
|
|
587
|
+
|
|
588
|
+
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
|
+
|
|
590
|
+
Parameters:
|
|
591
|
+
|
|
592
|
+
|param|type|description|
|
|
593
|
+
|-----|----|-----------|
|
|
594
|
+
|`x`|`Float64`|The operand|
|
|
595
|
+
|
|
596
|
+
Returns:
|
|
597
|
+
|
|
598
|
+
|type|description|
|
|
599
|
+
|----|-----------|
|
|
600
|
+
|`Float64`|The absolute value of the operand|
|
|
601
|
+
|
|
602
|
+
Examples:
|
|
603
|
+
|
|
604
|
+
```grain
|
|
605
|
+
Float64.abs(-1.0d) == 1.0d
|
|
606
|
+
```
|
|
607
|
+
|
|
608
|
+
```grain
|
|
609
|
+
Float64.abs(5.0d) == 5.0d
|
|
610
|
+
```
|
|
611
|
+
|
|
612
|
+
### Float64.**neg**
|
|
613
|
+
|
|
614
|
+
<details disabled>
|
|
615
|
+
<summary tabindex="-1">Added in <code>0.6.5</code></summary>
|
|
616
|
+
No other changes yet.
|
|
617
|
+
</details>
|
|
618
|
+
|
|
619
|
+
```grain
|
|
620
|
+
neg : (x: Float64) => Float64
|
|
621
|
+
```
|
|
622
|
+
|
|
623
|
+
Returns the negation of its operand.
|
|
624
|
+
|
|
625
|
+
Parameters:
|
|
626
|
+
|
|
627
|
+
|param|type|description|
|
|
628
|
+
|-----|----|-----------|
|
|
629
|
+
|`x`|`Float64`|The operand|
|
|
630
|
+
|
|
631
|
+
Returns:
|
|
632
|
+
|
|
633
|
+
|type|description|
|
|
634
|
+
|----|-----------|
|
|
635
|
+
|`Float64`|The negated operand|
|
|
636
|
+
|
|
637
|
+
Examples:
|
|
638
|
+
|
|
639
|
+
```grain
|
|
640
|
+
Float64.neg(-1.0d) == 1.0d
|
|
641
|
+
```
|
|
642
|
+
|
|
643
|
+
```grain
|
|
644
|
+
Float64.neg(1.0d) == -1.0d
|
|
645
|
+
```
|
|
646
|
+
|
package/hash.gr
CHANGED
package/int16.gr
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
* Utilities for working with the Int16 type.
|
|
3
3
|
* @example from "int16" include Int16
|
|
4
4
|
*
|
|
5
|
+
* @example 1S
|
|
6
|
+
* @example -1S
|
|
7
|
+
*
|
|
5
8
|
* @since v0.6.0
|
|
6
9
|
*/
|
|
7
10
|
module Int16
|
|
@@ -51,6 +54,8 @@ let signExtend = x => (x << _DATA_OFFSET) >> _DATA_OFFSET
|
|
|
51
54
|
* @param number: The value to convert
|
|
52
55
|
* @returns The Uint16 represented as an Int16
|
|
53
56
|
*
|
|
57
|
+
* @example Int16.fromUint16(1uS) == 1S
|
|
58
|
+
*
|
|
54
59
|
* @since v0.6.0
|
|
55
60
|
*/
|
|
56
61
|
@unsafe
|
|
@@ -67,6 +72,9 @@ provide let fromUint16 = (number: Uint16) => {
|
|
|
67
72
|
* @param value: The value to increment
|
|
68
73
|
* @returns The incremented value
|
|
69
74
|
*
|
|
75
|
+
* @example Int16.incr(1S) == 2S
|
|
76
|
+
* @example Int16.incr(-2S) == -1S
|
|
77
|
+
*
|
|
70
78
|
* @since v0.6.0
|
|
71
79
|
*/
|
|
72
80
|
@unsafe
|
|
@@ -83,6 +91,9 @@ provide let incr = (value: Int16) => {
|
|
|
83
91
|
* @param value: The value to decrement
|
|
84
92
|
* @returns The decremented value
|
|
85
93
|
*
|
|
94
|
+
* @example Int16.decr(2S) == 1S
|
|
95
|
+
* @example Int16.decr(0S) == -1S
|
|
96
|
+
*
|
|
86
97
|
* @since v0.6.0
|
|
87
98
|
*/
|
|
88
99
|
@unsafe
|
|
@@ -100,6 +111,10 @@ provide let decr = (value: Int16) => {
|
|
|
100
111
|
* @param y: The second operand
|
|
101
112
|
* @returns The sum of the two operands
|
|
102
113
|
*
|
|
114
|
+
* @example
|
|
115
|
+
* use Int16.{ (+) }
|
|
116
|
+
* assert 1S + 1S == 2S
|
|
117
|
+
*
|
|
103
118
|
* @since v0.6.0
|
|
104
119
|
*/
|
|
105
120
|
@unsafe
|
|
@@ -121,6 +136,10 @@ provide let (+) = (x: Int16, y: Int16) => {
|
|
|
121
136
|
* @param y: The second operand
|
|
122
137
|
* @returns The difference of the two operands
|
|
123
138
|
*
|
|
139
|
+
* @example
|
|
140
|
+
* use Int16.{ (-) }
|
|
141
|
+
* assert 2S - 1S == 1S
|
|
142
|
+
*
|
|
124
143
|
* @since v0.6.0
|
|
125
144
|
*/
|
|
126
145
|
@unsafe
|
|
@@ -139,6 +158,10 @@ provide let (-) = (x: Int16, y: Int16) => {
|
|
|
139
158
|
* @param y: The second operand
|
|
140
159
|
* @returns The product of the two operands
|
|
141
160
|
*
|
|
161
|
+
* @example
|
|
162
|
+
* use Int16.{ (*) }
|
|
163
|
+
* assert 2S * 2S == 4S
|
|
164
|
+
*
|
|
142
165
|
* @since v0.6.0
|
|
143
166
|
*/
|
|
144
167
|
@unsafe
|
|
@@ -156,6 +179,10 @@ provide let (*) = (x: Int16, y: Int16) => {
|
|
|
156
179
|
* @param y: The second operand
|
|
157
180
|
* @returns The quotient of its operands
|
|
158
181
|
*
|
|
182
|
+
* @example
|
|
183
|
+
* use Int16.{ (/) }
|
|
184
|
+
* assert 8S / 2S == 4S
|
|
185
|
+
*
|
|
159
186
|
* @since v0.6.0
|
|
160
187
|
*/
|
|
161
188
|
@unsafe
|
|
@@ -174,6 +201,8 @@ provide let (/) = (x: Int16, y: Int16) => {
|
|
|
174
201
|
* @param y: The second operand
|
|
175
202
|
* @returns The remainder of its operands
|
|
176
203
|
*
|
|
204
|
+
* @example Int16.rem(8S, 3S) == 2S
|
|
205
|
+
*
|
|
177
206
|
* @since v0.6.0
|
|
178
207
|
*/
|
|
179
208
|
@unsafe
|
|
@@ -202,6 +231,10 @@ let abs = n => {
|
|
|
202
231
|
*
|
|
203
232
|
* @throws ModuloByZero: When `y` is zero
|
|
204
233
|
*
|
|
234
|
+
* @example
|
|
235
|
+
* use Int16.{ (%) }
|
|
236
|
+
* assert -5S % 3S == 1S
|
|
237
|
+
*
|
|
205
238
|
* @since v0.6.0
|
|
206
239
|
*/
|
|
207
240
|
@unsafe
|
|
@@ -233,6 +266,10 @@ provide let (%) = (x: Int16, y: Int16) => {
|
|
|
233
266
|
* @param amount: The number of bits to shift by
|
|
234
267
|
* @returns The shifted value
|
|
235
268
|
*
|
|
269
|
+
* @example
|
|
270
|
+
* use Int16.{ (<<) }
|
|
271
|
+
* assert (5S << 1S) == 10S
|
|
272
|
+
*
|
|
236
273
|
* @since v0.6.0
|
|
237
274
|
*/
|
|
238
275
|
@unsafe
|
|
@@ -252,6 +289,10 @@ provide let (<<) = (value: Int16, amount: Int16) => {
|
|
|
252
289
|
* @param amount: The amount to shift by
|
|
253
290
|
* @returns The shifted value
|
|
254
291
|
*
|
|
292
|
+
* @example
|
|
293
|
+
* use Int16.{ (>>) }
|
|
294
|
+
* assert (5S >> 1S) == 2S
|
|
295
|
+
*
|
|
255
296
|
* @since v0.6.0
|
|
256
297
|
*/
|
|
257
298
|
@unsafe
|
|
@@ -271,6 +312,10 @@ provide let (>>) = (value: Int16, amount: Int16) => {
|
|
|
271
312
|
* @param y: The second value
|
|
272
313
|
* @returns `true` if the first value is equal to the second value or `false` otherwise
|
|
273
314
|
*
|
|
315
|
+
* @example
|
|
316
|
+
* use Int16.{ (==) }
|
|
317
|
+
* assert 1S == 1S
|
|
318
|
+
*
|
|
274
319
|
* @since v0.6.0
|
|
275
320
|
*/
|
|
276
321
|
@unsafe
|
|
@@ -287,6 +332,10 @@ provide let (==) = (x: Int16, y: Int16) => {
|
|
|
287
332
|
* @param y: The second value
|
|
288
333
|
* @returns `true` if the first value is not equal to the second value or `false` otherwise
|
|
289
334
|
*
|
|
335
|
+
* @example
|
|
336
|
+
* use Int16.{ (!=) }
|
|
337
|
+
* assert 1S != 2S
|
|
338
|
+
*
|
|
290
339
|
* @since v0.6.0
|
|
291
340
|
*/
|
|
292
341
|
@unsafe
|
|
@@ -303,6 +352,10 @@ provide let (!=) = (x: Int16, y: Int16) => {
|
|
|
303
352
|
* @param y: The second value
|
|
304
353
|
* @returns `true` if the first value is less than the second value or `false` otherwise
|
|
305
354
|
*
|
|
355
|
+
* @example
|
|
356
|
+
* use Int16.{ (<) }
|
|
357
|
+
* assert 1S < 2S
|
|
358
|
+
*
|
|
306
359
|
* @since v0.6.0
|
|
307
360
|
*/
|
|
308
361
|
@unsafe
|
|
@@ -319,6 +372,10 @@ provide let (<) = (x: Int16, y: Int16) => {
|
|
|
319
372
|
* @param y: The second value
|
|
320
373
|
* @returns `true` if the first value is greater than the second value or `false` otherwise
|
|
321
374
|
*
|
|
375
|
+
* @example
|
|
376
|
+
* use Int16.{ (>) }
|
|
377
|
+
* assert 2S > 1S
|
|
378
|
+
*
|
|
322
379
|
* @since v0.6.0
|
|
323
380
|
*/
|
|
324
381
|
@unsafe
|
|
@@ -335,6 +392,13 @@ provide let (>) = (x: Int16, y: Int16) => {
|
|
|
335
392
|
* @param y: The second value
|
|
336
393
|
* @returns `true` if the first value is less than or equal to the second value or `false` otherwise
|
|
337
394
|
*
|
|
395
|
+
* @example
|
|
396
|
+
* use Int16.{ (<=) }
|
|
397
|
+
* assert 1S <= 2S
|
|
398
|
+
* @example
|
|
399
|
+
* use Int16.{ (<=) }
|
|
400
|
+
* assert 1S <= 1S
|
|
401
|
+
*
|
|
338
402
|
* @since v0.6.0
|
|
339
403
|
*/
|
|
340
404
|
@unsafe
|
|
@@ -351,6 +415,13 @@ provide let (<=) = (x: Int16, y: Int16) => {
|
|
|
351
415
|
* @param y: The second value
|
|
352
416
|
* @returns `true` if the first value is greater than or equal to the second value or `false` otherwise
|
|
353
417
|
*
|
|
418
|
+
* @example
|
|
419
|
+
* use Int16.{ (>=) }
|
|
420
|
+
* assert 2S >= 1S
|
|
421
|
+
* @example
|
|
422
|
+
* use Int16.{ (>=) }
|
|
423
|
+
* assert 1S >= 1S
|
|
424
|
+
*
|
|
354
425
|
* @since v0.6.0
|
|
355
426
|
*/
|
|
356
427
|
@unsafe
|
|
@@ -366,6 +437,8 @@ provide let (>=) = (x: Int16, y: Int16) => {
|
|
|
366
437
|
* @param value: The given value
|
|
367
438
|
* @returns Containing the inverted bits of the given value
|
|
368
439
|
*
|
|
440
|
+
* @example Int16.lnot(-5S) == 4S
|
|
441
|
+
*
|
|
369
442
|
* @since v0.6.0
|
|
370
443
|
*/
|
|
371
444
|
@unsafe
|
|
@@ -381,6 +454,10 @@ provide let lnot = (value: Int16) => {
|
|
|
381
454
|
* @param y: The second operand
|
|
382
455
|
* @returns Containing a `1` in each bit position for which the corresponding bits of both operands are `1`
|
|
383
456
|
*
|
|
457
|
+
* @example
|
|
458
|
+
* use Int16.{ (&) }
|
|
459
|
+
* assert (3S & 4S) == 0S
|
|
460
|
+
*
|
|
384
461
|
* @since v0.6.0
|
|
385
462
|
*/
|
|
386
463
|
@unsafe
|
|
@@ -399,6 +476,10 @@ provide let (&) = (x: Int16, y: Int16) => {
|
|
|
399
476
|
* @param y: The second operand
|
|
400
477
|
* @returns Containing a `1` in each bit position for which the corresponding bits of either or both operands are `1`
|
|
401
478
|
*
|
|
479
|
+
* @example
|
|
480
|
+
* use Int16.{ (|) }
|
|
481
|
+
* assert (3S | 4S) == 7S
|
|
482
|
+
*
|
|
402
483
|
* @since v0.6.0
|
|
403
484
|
*/
|
|
404
485
|
@unsafe
|
|
@@ -417,6 +498,10 @@ provide let (|) = (x: Int16, y: Int16) => {
|
|
|
417
498
|
* @param y: The second operand
|
|
418
499
|
* @returns Containing a `1` in each bit position for which the corresponding bits of either but not both operands are `1`
|
|
419
500
|
*
|
|
501
|
+
* @example
|
|
502
|
+
* use Int16.{ (^) }
|
|
503
|
+
* assert (3S ^ 5S) == 6S
|
|
504
|
+
*
|
|
420
505
|
* @since v0.6.0
|
|
421
506
|
*/
|
|
422
507
|
@unsafe
|
package/int16.md
CHANGED
|
@@ -13,6 +13,14 @@ No other changes yet.
|
|
|
13
13
|
from "int16" include Int16
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
+
```grain
|
|
17
|
+
1S
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
```grain
|
|
21
|
+
-1S
|
|
22
|
+
```
|
|
23
|
+
|
|
16
24
|
## Values
|
|
17
25
|
|
|
18
26
|
Functions and constants included in the Int16 module.
|
|
@@ -92,6 +100,12 @@ Returns:
|
|
|
92
100
|
|----|-----------|
|
|
93
101
|
|`Int16`|The Uint16 represented as an Int16|
|
|
94
102
|
|
|
103
|
+
Examples:
|
|
104
|
+
|
|
105
|
+
```grain
|
|
106
|
+
Int16.fromUint16(1uS) == 1S
|
|
107
|
+
```
|
|
108
|
+
|
|
95
109
|
### Int16.**incr**
|
|
96
110
|
|
|
97
111
|
<details disabled>
|
|
@@ -117,6 +131,16 @@ Returns:
|
|
|
117
131
|
|----|-----------|
|
|
118
132
|
|`Int16`|The incremented value|
|
|
119
133
|
|
|
134
|
+
Examples:
|
|
135
|
+
|
|
136
|
+
```grain
|
|
137
|
+
Int16.incr(1S) == 2S
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
```grain
|
|
141
|
+
Int16.incr(-2S) == -1S
|
|
142
|
+
```
|
|
143
|
+
|
|
120
144
|
### Int16.**decr**
|
|
121
145
|
|
|
122
146
|
<details disabled>
|
|
@@ -142,6 +166,16 @@ Returns:
|
|
|
142
166
|
|----|-----------|
|
|
143
167
|
|`Int16`|The decremented value|
|
|
144
168
|
|
|
169
|
+
Examples:
|
|
170
|
+
|
|
171
|
+
```grain
|
|
172
|
+
Int16.decr(2S) == 1S
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
```grain
|
|
176
|
+
Int16.decr(0S) == -1S
|
|
177
|
+
```
|
|
178
|
+
|
|
145
179
|
### Int16.**(+)**
|
|
146
180
|
|
|
147
181
|
<details disabled>
|
|
@@ -168,6 +202,13 @@ Returns:
|
|
|
168
202
|
|----|-----------|
|
|
169
203
|
|`Int16`|The sum of the two operands|
|
|
170
204
|
|
|
205
|
+
Examples:
|
|
206
|
+
|
|
207
|
+
```grain
|
|
208
|
+
use Int16.{ (+) }
|
|
209
|
+
assert 1S + 1S == 2S
|
|
210
|
+
```
|
|
211
|
+
|
|
171
212
|
### Int16.**(-)**
|
|
172
213
|
|
|
173
214
|
<details disabled>
|
|
@@ -194,6 +235,13 @@ Returns:
|
|
|
194
235
|
|----|-----------|
|
|
195
236
|
|`Int16`|The difference of the two operands|
|
|
196
237
|
|
|
238
|
+
Examples:
|
|
239
|
+
|
|
240
|
+
```grain
|
|
241
|
+
use Int16.{ (-) }
|
|
242
|
+
assert 2S - 1S == 1S
|
|
243
|
+
```
|
|
244
|
+
|
|
197
245
|
### Int16.**(*)**
|
|
198
246
|
|
|
199
247
|
<details disabled>
|
|
@@ -220,6 +268,13 @@ Returns:
|
|
|
220
268
|
|----|-----------|
|
|
221
269
|
|`Int16`|The product of the two operands|
|
|
222
270
|
|
|
271
|
+
Examples:
|
|
272
|
+
|
|
273
|
+
```grain
|
|
274
|
+
use Int16.{ (*) }
|
|
275
|
+
assert 2S * 2S == 4S
|
|
276
|
+
```
|
|
277
|
+
|
|
223
278
|
### Int16.**(/)**
|
|
224
279
|
|
|
225
280
|
<details disabled>
|
|
@@ -246,6 +301,13 @@ Returns:
|
|
|
246
301
|
|----|-----------|
|
|
247
302
|
|`Int16`|The quotient of its operands|
|
|
248
303
|
|
|
304
|
+
Examples:
|
|
305
|
+
|
|
306
|
+
```grain
|
|
307
|
+
use Int16.{ (/) }
|
|
308
|
+
assert 8S / 2S == 4S
|
|
309
|
+
```
|
|
310
|
+
|
|
249
311
|
### Int16.**rem**
|
|
250
312
|
|
|
251
313
|
<details disabled>
|
|
@@ -272,6 +334,12 @@ Returns:
|
|
|
272
334
|
|----|-----------|
|
|
273
335
|
|`Int16`|The remainder of its operands|
|
|
274
336
|
|
|
337
|
+
Examples:
|
|
338
|
+
|
|
339
|
+
```grain
|
|
340
|
+
Int16.rem(8S, 3S) == 2S
|
|
341
|
+
```
|
|
342
|
+
|
|
275
343
|
### Int16.**(%)**
|
|
276
344
|
|
|
277
345
|
<details disabled>
|
|
@@ -305,6 +373,13 @@ Throws:
|
|
|
305
373
|
|
|
306
374
|
* When `y` is zero
|
|
307
375
|
|
|
376
|
+
Examples:
|
|
377
|
+
|
|
378
|
+
```grain
|
|
379
|
+
use Int16.{ (%) }
|
|
380
|
+
assert -5S % 3S == 1S
|
|
381
|
+
```
|
|
382
|
+
|
|
308
383
|
### Int16.**(<<)**
|
|
309
384
|
|
|
310
385
|
<details disabled>
|
|
@@ -331,6 +406,13 @@ Returns:
|
|
|
331
406
|
|----|-----------|
|
|
332
407
|
|`Int16`|The shifted value|
|
|
333
408
|
|
|
409
|
+
Examples:
|
|
410
|
+
|
|
411
|
+
```grain
|
|
412
|
+
use Int16.{ (<<) }
|
|
413
|
+
assert (5S << 1S) == 10S
|
|
414
|
+
```
|
|
415
|
+
|
|
334
416
|
### Int16.**(>>)**
|
|
335
417
|
|
|
336
418
|
<details disabled>
|
|
@@ -357,6 +439,13 @@ Returns:
|
|
|
357
439
|
|----|-----------|
|
|
358
440
|
|`Int16`|The shifted value|
|
|
359
441
|
|
|
442
|
+
Examples:
|
|
443
|
+
|
|
444
|
+
```grain
|
|
445
|
+
use Int16.{ (>>) }
|
|
446
|
+
assert (5S >> 1S) == 2S
|
|
447
|
+
```
|
|
448
|
+
|
|
360
449
|
### Int16.**(==)**
|
|
361
450
|
|
|
362
451
|
<details disabled>
|
|
@@ -383,6 +472,13 @@ Returns:
|
|
|
383
472
|
|----|-----------|
|
|
384
473
|
|`Bool`|`true` if the first value is equal to the second value or `false` otherwise|
|
|
385
474
|
|
|
475
|
+
Examples:
|
|
476
|
+
|
|
477
|
+
```grain
|
|
478
|
+
use Int16.{ (==) }
|
|
479
|
+
assert 1S == 1S
|
|
480
|
+
```
|
|
481
|
+
|
|
386
482
|
### Int16.**(!=)**
|
|
387
483
|
|
|
388
484
|
<details disabled>
|
|
@@ -409,6 +505,13 @@ Returns:
|
|
|
409
505
|
|----|-----------|
|
|
410
506
|
|`Bool`|`true` if the first value is not equal to the second value or `false` otherwise|
|
|
411
507
|
|
|
508
|
+
Examples:
|
|
509
|
+
|
|
510
|
+
```grain
|
|
511
|
+
use Int16.{ (!=) }
|
|
512
|
+
assert 1S != 2S
|
|
513
|
+
```
|
|
514
|
+
|
|
412
515
|
### Int16.**(<)**
|
|
413
516
|
|
|
414
517
|
<details disabled>
|
|
@@ -435,6 +538,13 @@ Returns:
|
|
|
435
538
|
|----|-----------|
|
|
436
539
|
|`Bool`|`true` if the first value is less than the second value or `false` otherwise|
|
|
437
540
|
|
|
541
|
+
Examples:
|
|
542
|
+
|
|
543
|
+
```grain
|
|
544
|
+
use Int16.{ (<) }
|
|
545
|
+
assert 1S < 2S
|
|
546
|
+
```
|
|
547
|
+
|
|
438
548
|
### Int16.**(>)**
|
|
439
549
|
|
|
440
550
|
<details disabled>
|
|
@@ -461,6 +571,13 @@ Returns:
|
|
|
461
571
|
|----|-----------|
|
|
462
572
|
|`Bool`|`true` if the first value is greater than the second value or `false` otherwise|
|
|
463
573
|
|
|
574
|
+
Examples:
|
|
575
|
+
|
|
576
|
+
```grain
|
|
577
|
+
use Int16.{ (>) }
|
|
578
|
+
assert 2S > 1S
|
|
579
|
+
```
|
|
580
|
+
|
|
464
581
|
### Int16.**(<=)**
|
|
465
582
|
|
|
466
583
|
<details disabled>
|
|
@@ -487,6 +604,18 @@ Returns:
|
|
|
487
604
|
|----|-----------|
|
|
488
605
|
|`Bool`|`true` if the first value is less than or equal to the second value or `false` otherwise|
|
|
489
606
|
|
|
607
|
+
Examples:
|
|
608
|
+
|
|
609
|
+
```grain
|
|
610
|
+
use Int16.{ (<=) }
|
|
611
|
+
assert 1S <= 2S
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
```grain
|
|
615
|
+
use Int16.{ (<=) }
|
|
616
|
+
assert 1S <= 1S
|
|
617
|
+
```
|
|
618
|
+
|
|
490
619
|
### Int16.**(>=)**
|
|
491
620
|
|
|
492
621
|
<details disabled>
|
|
@@ -513,6 +642,18 @@ Returns:
|
|
|
513
642
|
|----|-----------|
|
|
514
643
|
|`Bool`|`true` if the first value is greater than or equal to the second value or `false` otherwise|
|
|
515
644
|
|
|
645
|
+
Examples:
|
|
646
|
+
|
|
647
|
+
```grain
|
|
648
|
+
use Int16.{ (>=) }
|
|
649
|
+
assert 2S >= 1S
|
|
650
|
+
```
|
|
651
|
+
|
|
652
|
+
```grain
|
|
653
|
+
use Int16.{ (>=) }
|
|
654
|
+
assert 1S >= 1S
|
|
655
|
+
```
|
|
656
|
+
|
|
516
657
|
### Int16.**lnot**
|
|
517
658
|
|
|
518
659
|
<details disabled>
|
|
@@ -538,6 +679,12 @@ Returns:
|
|
|
538
679
|
|----|-----------|
|
|
539
680
|
|`Int16`|Containing the inverted bits of the given value|
|
|
540
681
|
|
|
682
|
+
Examples:
|
|
683
|
+
|
|
684
|
+
```grain
|
|
685
|
+
Int16.lnot(-5S) == 4S
|
|
686
|
+
```
|
|
687
|
+
|
|
541
688
|
### Int16.**(&)**
|
|
542
689
|
|
|
543
690
|
<details disabled>
|
|
@@ -564,6 +711,13 @@ Returns:
|
|
|
564
711
|
|----|-----------|
|
|
565
712
|
|`Int16`|Containing a `1` in each bit position for which the corresponding bits of both operands are `1`|
|
|
566
713
|
|
|
714
|
+
Examples:
|
|
715
|
+
|
|
716
|
+
```grain
|
|
717
|
+
use Int16.{ (&) }
|
|
718
|
+
assert (3S & 4S) == 0S
|
|
719
|
+
```
|
|
720
|
+
|
|
567
721
|
### Int16.**(|)**
|
|
568
722
|
|
|
569
723
|
<details disabled>
|
|
@@ -590,6 +744,13 @@ Returns:
|
|
|
590
744
|
|----|-----------|
|
|
591
745
|
|`Int16`|Containing a `1` in each bit position for which the corresponding bits of either or both operands are `1`|
|
|
592
746
|
|
|
747
|
+
Examples:
|
|
748
|
+
|
|
749
|
+
```grain
|
|
750
|
+
use Int16.{ (|) }
|
|
751
|
+
assert (3S | 4S) == 7S
|
|
752
|
+
```
|
|
753
|
+
|
|
593
754
|
### Int16.**(^)**
|
|
594
755
|
|
|
595
756
|
<details disabled>
|
|
@@ -616,3 +777,10 @@ Returns:
|
|
|
616
777
|
|----|-----------|
|
|
617
778
|
|`Int16`|Containing a `1` in each bit position for which the corresponding bits of either but not both operands are `1`|
|
|
618
779
|
|
|
780
|
+
Examples:
|
|
781
|
+
|
|
782
|
+
```grain
|
|
783
|
+
use Int16.{ (^) }
|
|
784
|
+
assert (3S ^ 5S) == 6S
|
|
785
|
+
```
|
|
786
|
+
|