Function ctz [src]

Returns the number of trailing zeros in twos-complement form.

Prototype

pub fn ctz(a: Const, bits: Limb) Limb

Parameters

a: Constbits: Limb

Source

pub fn ctz(a: Const, bits: Limb) Limb { // Limbs are stored in little-endian order. Converting a negative number to twos-complement // flips all bits above the lowest set bit, which does not affect the trailing zero count. if (a.eqlZero()) return bits; var result: Limb = 0; for (a.limbs) |limb| { const limb_tz = @ctz(limb); result += limb_tz; if (limb_tz != @bitSizeOf(Limb)) break; } return @min(result, bits); }