@@ -98,7 +98,7 @@ extension type const Int16._(int _) implements int {
98
98
static bool isValid (int v) => v >= minInt && v <= maxInt;
99
99
100
100
/// Returns [value] if its in a valid range for Int16.
101
- static Int16 checkRange (int value) {
101
+ factory Int16 . checkRange (int value) {
102
102
RangeError .checkValueInInterval (value, minInt, maxInt, 'value' );
103
103
return Int16 .fromUnchecked (value);
104
104
}
@@ -335,13 +335,18 @@ extension type const Int16._(int _) implements int {
335
335
}
336
336
337
337
/// Returns whether the n-th bit is set.
338
- bool nthBit (int n) => _ .nthBit (n);
338
+ bool nthBit (int n) => _descriptor .nthBit (_, n);
339
339
340
340
/// Returns whether the n-th bit is set.
341
341
///
342
342
/// This is an alias for [nthBit] .
343
343
bool operator [](int n) => nthBit (n);
344
344
345
+ /// Returns whether the least significant bit is set.
346
+ ///
347
+ /// This is equivalent to `nthBit(0)` .
348
+ bool get lsb => nthBit (0 );
349
+
345
350
/// Returns whether the most significant bit is set.
346
351
///
347
352
/// This is equivalent to `nthBit(width - 1)` .
@@ -399,7 +404,9 @@ extension type const Int16._(int _) implements int {
399
404
/// ```dart
400
405
/// Int16(3).nextPowerOf2(); // 4
401
406
/// ```
402
- Int16 nextPowerOf2 () => Int16 (_.nextPowerOf2 ());
407
+ Int16 nextPowerOf2 () {
408
+ return Int16 (_descriptor.overflowingNextPowerOf2 (_));
409
+ }
403
410
404
411
/// Returns the smallest power of two greater than or equal to `this` .
405
412
///
@@ -408,7 +415,9 @@ extension type const Int16._(int _) implements int {
408
415
/// `this` must be a positive integer.
409
416
///
410
417
/// If the result is out of range, the behavior is undefined.
411
- Int16 uncheckedNextPowerOf2 () => Int16 .fromUnchecked (_.nextPowerOf2 ());
418
+ Int16 uncheckedNextPowerOf2 () {
419
+ return Int16 .fromUnchecked (_descriptor.overflowingNextPowerOf2 (_));
420
+ }
412
421
413
422
/// Returns the smallest power of two greater than or equal to `this` .
414
423
///
@@ -428,7 +437,9 @@ extension type const Int16._(int _) implements int {
428
437
/// ```dart
429
438
/// Int16(3).tryNextPowerOf2(); // 4
430
439
/// ```
431
- Int16 ? tryNextPowerOf2 () => tryFrom (_.nextPowerOf2 ());
440
+ Int16 ? tryNextPowerOf2 () {
441
+ return tryFrom (_descriptor.overflowingNextPowerOf2 (_));
442
+ }
432
443
433
444
/// Returns the smallest power of two greater than or equal to `this` .
434
445
///
@@ -448,7 +459,9 @@ extension type const Int16._(int _) implements int {
448
459
/// ```dart
449
460
/// Int16(3).wrappedNextPowerOf2(); // 4
450
461
/// ```
451
- Int16 wrappedNextPowerOf2 () => Int16 .fromWrapped (_.nextPowerOf2 ());
462
+ Int16 wrappedNextPowerOf2 () {
463
+ return Int16 .fromWrapped (_descriptor.overflowingNextPowerOf2 (_));
464
+ }
452
465
453
466
/// Returns the smallest power of two greater than or equal to `this` .
454
467
///
@@ -468,7 +481,9 @@ extension type const Int16._(int _) implements int {
468
481
/// ```dart
469
482
/// Int16(3).clampedNextPowerOf2(); // 4
470
483
/// ```
471
- Int16 clampedNextPowerOf2 () => Int16 .fromClamped (_.nextPowerOf2 ());
484
+ Int16 clampedNextPowerOf2 () {
485
+ return Int16 .fromClamped (_descriptor.overflowingNextPowerOf2 (_));
486
+ }
472
487
473
488
/// Calculates the smallest value greater than or equal to `this` that is
474
489
/// a multiple of [n] .
@@ -488,7 +503,9 @@ extension type const Int16._(int _) implements int {
488
503
/// ```dart
489
504
/// Int16(3).nextMultipleOf(2); // 4
490
505
/// ```
491
- Int16 nextMultipleOf (Int16 n) => Int16 (_.nextMultipleOf (n._));
506
+ Int16 nextMultipleOf (Int16 n) {
507
+ return Int16 (_descriptor.overflowingNextMultipleOf (_, n));
508
+ }
492
509
493
510
/// Calculates the smallest value greater than or equal to `this` that is
494
511
///
@@ -498,7 +515,7 @@ extension type const Int16._(int _) implements int {
498
515
///
499
516
/// If the result is out of range, the behavior is undefined.
500
517
Int16 uncheckedNextMultipleOf (Int16 n) {
501
- return Int16 .fromUnchecked (_. nextMultipleOf (n._ ));
518
+ return Int16 .fromUnchecked (_descriptor. overflowingNextMultipleOf (_, n ));
502
519
}
503
520
504
521
/// Calculates the smallest value greater than or equal to `this` that is
@@ -519,7 +536,9 @@ extension type const Int16._(int _) implements int {
519
536
/// ```dart
520
537
/// Int16(3).tryNextMultipleOf(2); // 4
521
538
/// ```
522
- Int16 ? tryNextMultipleOf (Int16 n) => tryFrom (_.nextMultipleOf (n._));
539
+ Int16 ? tryNextMultipleOf (Int16 n) {
540
+ return tryFrom (_descriptor.overflowingNextMultipleOf (_, n));
541
+ }
523
542
524
543
/// Calculates the smallest value greater than or equal to `this` that is
525
544
/// a multiple of [n] .
@@ -540,7 +559,7 @@ extension type const Int16._(int _) implements int {
540
559
/// Int16(3).wrappedNextMultipleOf(2); // 4
541
560
/// ```
542
561
Int16 wrappedNextMultipleOf (Int16 n) {
543
- return Int16 .fromWrapped (_. nextMultipleOf (n._ ));
562
+ return Int16 .fromWrapped (_descriptor. overflowingNextMultipleOf (_, n ));
544
563
}
545
564
546
565
/// Calculates the smallest value greater than or equal to `this` that is
@@ -562,7 +581,7 @@ extension type const Int16._(int _) implements int {
562
581
/// Int16(3).clampedNextMultipleOf(2); // 4
563
582
/// ```
564
583
Int16 clampedNextMultipleOf (Int16 n) {
565
- return Int16 .fromClamped (_. nextMultipleOf (n._ ));
584
+ return Int16 .fromClamped (_descriptor. overflowingNextMultipleOf (_, n ));
566
585
}
567
586
568
587
/// Returns the number of `1` s in the binary representation of `this` .
0 commit comments