Function bitwise::word::shift_arithmetic_right [] [src]

pub fn shift_arithmetic_right<T: Word, U: UnsignedWord>(x: T, n: U) -> T

Shift the bits of x to the right by n; the high-order bits of the result are set to the value of the most significant bit of x.

Panics

If n > bit_size().

Examples

use bitwise::word::*;

let a = 0b0111_0000u8;
let b = 0b1001_0000u8;

assert_eq!(a.shift_arithmetic_right(4u8), 0b0000_0111u8);
assert_eq!(shift_arithmetic_right(b, 4u8), 0b1111_1001u8);
b.shift_arithmetic_right(u8::bit_size() - 1);