Trait malachite_base::num::logic::traits::SignificantBits
source · 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
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
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
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
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
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
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.