In Rust all primitive types have methods count_zeros, count_ones, leading_zeros and trailing_zeros. So create better parity with ApInt we should implement those small utility functions. This also helps for implementing higher level data structures later on, such as SignedApInt etc.
This issue proposes the addition of the following methods
[ ] fn count_zeros(&self) -> usize
Counts all zero bits in the ApInt.
[ ] fn count_ones(&self) -> usize
Counts all one bits in the ApInt.
[ ] fn leading_zeros(&self) -> usize
Counts all zero bits up to the first one bit in the ApInt.
[ ] fn trailing_zeros(&self) -> usize
Counts all zero bits after the last one bit in the ApInt.
Open Questions
Where are those new methods defined?
Since these methods operate mostly on the bit-level representation of the ApInt the submodule that currently fits best is the bitwise submodule within the apint module.
What means "first" and "last" in the context of leading_zeros and trailing_zeros?
In Rust "first" stands for most-significant-bit and "last" for least-significant-bit.
In Rust all primitive types have methods
count_zeros
,count_ones
,leading_zeros
andtrailing_zeros
. So create better parity withApInt
we should implement those small utility functions. This also helps for implementing higher level data structures later on, such asSignedApInt
etc.This issue proposes the addition of the following methods
fn count_zeros(&self) -> usize
fn count_ones(&self) -> usize
fn leading_zeros(&self) -> usize
fn trailing_zeros(&self) -> usize
Open Questions
leading_zeros
andtrailing_zeros
?