Skip to main content

carry_save_adder

Function carry_save_adder 

Source
pub fn carry_save_adder<T: UnsignedInteger>(a: T, b: T, c: T) -> (T, T)
Expand description

Computes the population count for each bit position across 3 input masks.

Returns two masks (bit0, bit1) that encode, per bit position, the 2-bit count of how many of the 3 inputs have that bit set.

For example, if a given bit is set in all 3 inputs, then that bit would be set in both bit0 and bit1.

ยงExamples

let (bit0, bit1) = carry_save_adder::<u8>(
    0b1000,
    0b1100,
    0b1110,
);
assert_eq!(bit0, 0b1010);
assert_eq!(bit1, 0b1100);