Module malachite_base::num::arithmetic::rotate

source ·
Expand description

RotateLeft, RotateLeftAssign, RotateRight, and RotateRightAssign, traits for rotating a number’s bits.

§rotate_left_assign

use malachite_base::num::arithmetic::traits::RotateLeftAssign;

let mut x: u32 = 0xabcd6789;
x.rotate_left_assign(4);
assert_eq!(x, 0xbcd6789a);

x = 0xabcd6789;
x.rotate_left_assign(32);
assert_eq!(x, 0xabcd6789);

x = 0xabcd6789;
x.rotate_left_assign(36);
assert_eq!(x, 0xbcd6789a);

§rotate_right_assign

use malachite_base::num::arithmetic::traits::RotateRightAssign;

let mut x: u32 = 0xabcd6789;
x.rotate_right_assign(4);
assert_eq!(x, 0x9abcd678);

x = 0xabcd6789;
x.rotate_right_assign(32);
assert_eq!(x, 0xabcd6789);

x = 0xabcd6789;
x.rotate_right_assign(36);
assert_eq!(x, 0x9abcd678);