pub trait SignificantBits {
    fn significant_bits(self) -> u64;
}

Required Methods

The number of bits it takes to represent self.

Implementations on Foreign Types

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

Implementors