-
Notifications
You must be signed in to change notification settings - Fork 23
Update numberOf{Leading,Trailing}Zeros documentation #119
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something left over here? "bit max.bit length". I don't know what a "bit max" is, and it's not defined. Maybe: /// For the value zero, the number of leading zeros is the entire
/// number of bits of the type (64 for [Int64], 32 for [Int32]). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe also worth adding that /// Negative numbers have no leading zero bits, their most signfiicant
/// bit is always set. |
||
/// 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Drop "Returns" here too. |
||
/// integer's two's complement representation. | ||
/// | ||
/// For zero, the result is the same as the integer type's bit max. bit | ||
/// length. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same phrase, /// For the value zero, the number of leading zeros is the entire
/// number of bits of the type (64 for [Int64], 32 for [Int32]). And consider adding /// Odd numbers have no trailing zero bits, their least significant bit
/// is always set. It's just explanatory, but may help intuition. Can also add /// A number `n` is evenly divisible by `pow(2, n.numberOfTrailingZeros())`. as another intuitional hint, building on the |
||
int numberOfTrailingZeros(); | ||
|
||
/// Returns the least significant [width] bits of this integer, extending the | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're touching this, remove the "Returns". It's a getter, so document using a noun phrase.
(Actually, it's not a getter. It definitely should have been. But it's named as one, with a noun phrase name, so it should still be documented the same way.)