Skip to main content

BitOps

Trait BitOps 

Source
pub trait BitOps {
Show 15 methods // Required methods fn bits_precision(&self) -> u32; fn bytes_precision(&self) -> usize; fn bit(&self, index: u32) -> Choice; fn set_bit(&mut self, index: u32, bit_value: Choice); fn trailing_zeros(&self) -> u32; fn trailing_ones(&self) -> u32; fn leading_zeros(&self) -> u32; fn bit_vartime(&self, index: u32) -> bool; fn set_bit_vartime(&mut self, index: u32, bit_value: bool); // Provided methods fn log2_bits(&self) -> u32 { ... } fn bits(&self) -> u32 { ... } fn bits_vartime(&self) -> u32 { ... } fn leading_zeros_vartime(&self) -> u32 { ... } fn trailing_zeros_vartime(&self) -> u32 { ... } fn trailing_ones_vartime(&self) -> u32 { ... }
}
Expand description

Bit counting and bit operations.

Required Methods§

Source

fn bits_precision(&self) -> u32

Precision of this integer in bits.

Source

fn bytes_precision(&self) -> usize

Precision of this integer in bytes.

Source

fn bit(&self, index: u32) -> Choice

Get the value of the bit at position index, as a truthy or falsy Choice. Returns the falsy value for indices out of range.

Source

fn set_bit(&mut self, index: u32, bit_value: Choice)

Sets the bit at index to 0 or 1 depending on the value of bit_value.

Source

fn trailing_zeros(&self) -> u32

Calculate the number of trailing zeros in the binary representation of this number.

Source

fn trailing_ones(&self) -> u32

Calculate the number of trailing ones in the binary representation of this number.

Source

fn leading_zeros(&self) -> u32

Calculate the number of leading zeros in the binary representation of this number.

Source

fn bit_vartime(&self, index: u32) -> bool

Returns true if the bit at position index is set, false otherwise.

§Remarks

This operation is variable time with respect to index only.

Source

fn set_bit_vartime(&mut self, index: u32, bit_value: bool)

Sets the bit at index to 0 or 1 depending on the value of bit_value, variable time in self.

Provided Methods§

Source

fn log2_bits(&self) -> u32

floor(log2(self.bits_precision())).

Source

fn bits(&self) -> u32

Calculate the number of bits required to represent a given number.

Source

fn bits_vartime(&self) -> u32

Calculate the number of bits required to represent a given number in variable-time with respect to self.

Source

fn leading_zeros_vartime(&self) -> u32

Calculate the number of leading zeros in the binary representation of this number.

Source

fn trailing_zeros_vartime(&self) -> u32

Calculate the number of trailing zeros in the binary representation of this number in variable-time with respect to self.

Source

fn trailing_ones_vartime(&self) -> u32

Calculate the number of trailing ones in the binary representation of this number, variable time in self.

Implementors§

Source§

impl BitOps for BoxedUint

Available on crate feature alloc only.
Source§

impl BitOps for Limb

Source§

impl BitOps for UintRef

Source§

impl<const LIMBS: usize> BitOps for Uint<LIMBS>