Function glm::builtin::bitfieldExtract [] [src]

pub fn bitfieldExtract<I: BaseInt, T: GenInt<I>>(
    value: T,
    offset: usize,
    bits: usize
) -> T

Extracts bits [offset, offset + bits - 1] from value, returning them in the least significant bits of the result.

For unsigned data types, the most significant bits of the result will be set to zero. For signed data types, the most significant bits will be set to the value of bit offset + base – 1.

If bits is zero, the result will be zero. The result will be undefined if offset or bits is negative, or if the sum of offset and bits is greater than the number of bits used to store the operand.

Example

use glm::bitfieldExtract;

assert_eq!(bitfieldExtract(0xF000FFFF, 32, 12), 0);
assert_eq!(bitfieldExtract(0b11100011_u32, 1, 6), 0b110001);