Lines Matching refs:SHIFT
500 /// Right-shifts `self` by `SHIFT` and returns the result as a `Bounded<_, RES>`, where `RES >=
501 /// N - SHIFT`.
513 pub fn shr<const SHIFT: u32, const RES: u32>(self) -> Bounded<T, RES> {
514 const_assert!(SHIFT < T::BITS);
515 const_assert!(RES + SHIFT >= N);
517 // SAFETY: We shift the value right by `SHIFT`, reducing the number of bits needed to
518 // represent the shifted value by as much, and just asserted that `RES >= N - SHIFT`.
519 unsafe { Bounded::__new(self.0 >> SHIFT) }
522 /// Right-shifts `self` by `SHIFT` if that loses no set bits, and returns the result as a
523 /// `Bounded<_, RES>`, where `RES >= N - SHIFT`.
525 /// Returns [`None`] if any of the `SHIFT` least significant bits of `self` is set.
544 pub fn shr_exact<const SHIFT: u32, const RES: u32>(self) -> Option<Bounded<T, RES>> {
545 let shifted = self.shr::<SHIFT, RES>();
546 if shifted.get() << SHIFT == self.0 {
553 /// Left-shifts `self` by `SHIFT` and returns the result as a `Bounded<_, RES>`, where `RES >=
554 /// N + SHIFT`.
566 pub fn shl<const SHIFT: u32, const RES: u32>(self) -> Bounded<T, RES> {
567 const_assert!(RES >= N + SHIFT);
569 // SAFETY: We shift the value left by `SHIFT`, augmenting the number of bits needed to
570 // represent the shifted value by as much, and just asserted that `RES >= N + SHIFT`.
571 unsafe { Bounded::__new(self.0 << SHIFT) }