Skip to content
This repository has been archived by the owner on Oct 17, 2024. It is now read-only.

Commit

Permalink
Update numberOf{Leading,Trailing}Zeros documentation
Browse files Browse the repository at this point in the history
- Mention the result when the integer is 0.
- Clarify that leading = most significant, trailing = least signitifant.
  • Loading branch information
osa1 committed Oct 18, 2023
1 parent ef45eb5 commit fbfb812
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 0 additions & 4 deletions lib/src/int64.dart
Original file line number Diff line number Diff line change
Expand Up @@ -634,8 +634,6 @@ class Int64 implements IntX {
return this;
}

/// Returns the number of leading zeros in this [Int64] as an [int]
/// between 0 and 64.
@override
int numberOfLeadingZeros() {
int b2 = u.numberOfLeadingZeros(_h);
Expand All @@ -651,8 +649,6 @@ class Int64 implements IntX {
}
}

/// Returns the number of trailing zeros in this [Int64] as an [int]
/// between 0 and 64.
@override
int numberOfTrailingZeros() {
int zeros = u.numberOfTrailingZeros(_l);
Expand Down
14 changes: 10 additions & 4 deletions lib/src/intx.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,18 @@ abstract class IntX implements Comparable<Object> {
/// value, add one, i.e. use `x.bitLength + 1`.
int get bitLength;

/// Returns the number of high-order zeros in this integer's bit
/// representation.
/// Returns the number of leading (most significant) zeros in this integer's
/// two's complement representation.
///
/// For zero, the result is the same as the integer type's bit max. bit
/// length.
int numberOfLeadingZeros();

/// Returns the number of low-order zeros in this integer's bit
/// representation.
/// Returns the number of trailing (least significant) zeros in this
/// integer's two's complement representation.
///
/// For zero, the result is the same as the integer type's bit max. bit
/// length.
int numberOfTrailingZeros();

/// Returns the least significant [width] bits of this integer, extending the
Expand Down

0 comments on commit fbfb812

Please sign in to comment.