Jcd.BitManipulation

A bit manipulation readability enhancement library.

Jcd.BitManipulation

Jcd.BitManipulation.Algorithms.SByteAlgorithmsExtensions

SByteAlgorithmsExtensions.CountTrailingZeros(this sbyte) Method

Computes the number of sequentially zeroed bits occupying the least significant bit positions.

public static int CountTrailingZeros(this sbyte number);

Parameters

number System.SByte

The number to evaluate.

Returns

System.Int32 The count of sequentially zeroed bits occupying the least significant bit positions.

Example

sbyte v = 1;
Console.WriteLine($"{v.CountTrailingZeros()}"); // outputs: 0

v = 2;
Console.WriteLine($"{v.CountTrailingZeros()}"); // outputs: 1

v = 3;
Console.WriteLine($"{v.CountTrailingZeros()}"); // outputs: 1

v = 4;
Console.WriteLine($"{v.CountTrailingZeros()}"); // outputs: 2