pub trait SignificantBits {
// Required method
fn significant_bits(self) -> u64;
}
Required Methods§
Sourcefn significant_bits(self) -> u64
fn significant_bits(self) -> u64
The number of bits it takes to represent self
.
Implementations on Foreign Types§
Source§impl SignificantBits for i8
Returns the number of significant bits of a signed primitive integer.
impl SignificantBits for i8
Returns the number of significant bits of a signed primitive integer.
This is the integer’s width minus the number of leading zeros of its absolute value.
$$ f(n) = \begin{cases} 0 & \text{if} \quad n = 0, \\ \lfloor \log_2 |n| \rfloor + 1 & \text{if} \quad n \neq 0. \end{cases} $$
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
fn significant_bits(self) -> u64
Source§impl SignificantBits for i16
Returns the number of significant bits of a signed primitive integer.
impl SignificantBits for i16
Returns the number of significant bits of a signed primitive integer.
This is the integer’s width minus the number of leading zeros of its absolute value.
$$ f(n) = \begin{cases} 0 & \text{if} \quad n = 0, \\ \lfloor \log_2 |n| \rfloor + 1 & \text{if} \quad n \neq 0. \end{cases} $$
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
fn significant_bits(self) -> u64
Source§impl SignificantBits for i32
Returns the number of significant bits of a signed primitive integer.
impl SignificantBits for i32
Returns the number of significant bits of a signed primitive integer.
This is the integer’s width minus the number of leading zeros of its absolute value.
$$ f(n) = \begin{cases} 0 & \text{if} \quad n = 0, \\ \lfloor \log_2 |n| \rfloor + 1 & \text{if} \quad n \neq 0. \end{cases} $$
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
fn significant_bits(self) -> u64
Source§impl SignificantBits for i64
Returns the number of significant bits of a signed primitive integer.
impl SignificantBits for i64
Returns the number of significant bits of a signed primitive integer.
This is the integer’s width minus the number of leading zeros of its absolute value.
$$ f(n) = \begin{cases} 0 & \text{if} \quad n = 0, \\ \lfloor \log_2 |n| \rfloor + 1 & \text{if} \quad n \neq 0. \end{cases} $$
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
fn significant_bits(self) -> u64
Source§impl SignificantBits for i128
Returns the number of significant bits of a signed primitive integer.
impl SignificantBits for i128
Returns the number of significant bits of a signed primitive integer.
This is the integer’s width minus the number of leading zeros of its absolute value.
$$ f(n) = \begin{cases} 0 & \text{if} \quad n = 0, \\ \lfloor \log_2 |n| \rfloor + 1 & \text{if} \quad n \neq 0. \end{cases} $$
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
fn significant_bits(self) -> u64
Source§impl SignificantBits for isize
Returns the number of significant bits of a signed primitive integer.
impl SignificantBits for isize
Returns the number of significant bits of a signed primitive integer.
This is the integer’s width minus the number of leading zeros of its absolute value.
$$ f(n) = \begin{cases} 0 & \text{if} \quad n = 0, \\ \lfloor \log_2 |n| \rfloor + 1 & \text{if} \quad n \neq 0. \end{cases} $$
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
fn significant_bits(self) -> u64
Source§impl SignificantBits for u8
impl SignificantBits for u8
Source§fn significant_bits(self) -> u64
fn significant_bits(self) -> u64
Returns the number of significant bits of an unsigned primitive integer.
This is the integer’s width minus the number of leading zeros.
$$ f(n) = \begin{cases} 0 & \text{if} \quad n = 0, \\ \lfloor \log_2 n \rfloor + 1 & \text{if} \quad n > 0. \end{cases} $$
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
Source§impl SignificantBits for u16
impl SignificantBits for u16
Source§fn significant_bits(self) -> u64
fn significant_bits(self) -> u64
Returns the number of significant bits of an unsigned primitive integer.
This is the integer’s width minus the number of leading zeros.
$$ f(n) = \begin{cases} 0 & \text{if} \quad n = 0, \\ \lfloor \log_2 n \rfloor + 1 & \text{if} \quad n > 0. \end{cases} $$
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
Source§impl SignificantBits for u32
impl SignificantBits for u32
Source§fn significant_bits(self) -> u64
fn significant_bits(self) -> u64
Returns the number of significant bits of an unsigned primitive integer.
This is the integer’s width minus the number of leading zeros.
$$ f(n) = \begin{cases} 0 & \text{if} \quad n = 0, \\ \lfloor \log_2 n \rfloor + 1 & \text{if} \quad n > 0. \end{cases} $$
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
Source§impl SignificantBits for u64
impl SignificantBits for u64
Source§fn significant_bits(self) -> u64
fn significant_bits(self) -> u64
Returns the number of significant bits of an unsigned primitive integer.
This is the integer’s width minus the number of leading zeros.
$$ f(n) = \begin{cases} 0 & \text{if} \quad n = 0, \\ \lfloor \log_2 n \rfloor + 1 & \text{if} \quad n > 0. \end{cases} $$
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
Source§impl SignificantBits for u128
impl SignificantBits for u128
Source§fn significant_bits(self) -> u64
fn significant_bits(self) -> u64
Returns the number of significant bits of an unsigned primitive integer.
This is the integer’s width minus the number of leading zeros.
$$ f(n) = \begin{cases} 0 & \text{if} \quad n = 0, \\ \lfloor \log_2 n \rfloor + 1 & \text{if} \quad n > 0. \end{cases} $$
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
Source§impl SignificantBits for usize
impl SignificantBits for usize
Source§fn significant_bits(self) -> u64
fn significant_bits(self) -> u64
Returns the number of significant bits of an unsigned primitive integer.
This is the integer’s width minus the number of leading zeros.
$$ f(n) = \begin{cases} 0 & \text{if} \quad n = 0, \\ \lfloor \log_2 n \rfloor + 1 & \text{if} \quad n > 0. \end{cases} $$
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.