License:
Public DomainAuthor:
Sean KellyReturns:
The bit number of the first bit set. The return value is undefined if v is zero.Returns:
The bit number of the first bit set. The return value is undefined if v is zero.Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | import tango.core.BitManip; int main() { uint v; int x; v = 0x21; x = bsf(v); printf("bsf(x%x) = %d\n", v, x); x = bsr(v); printf("bsr(x%x) = %d\n", v, x); return 0; } |
Output:
bsf(x21) = 0Params:
p | a non-NULL pointer to an array of size_ts. | ||
index | a bit number, starting with bit 0 of p[0],
and progressing. It addresses bits like the expression:
|
Returns:
A non-zero value if the bit was set, and a zero if it was clear.Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | import tango.core.BitManip; int main() { size_t array[2]; array[0] = 2; array[1] = 0x100; printf("btc(array, 35) = %d\n", btc(array, 35)); printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]); printf("btc(array, 35) = %d\n", btc(array, 35)); printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]); printf("bts(array, 35) = %d\n", bts(array, 35)); printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]); printf("btr(array, 35) = %d\n", btr(array, 35)); printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]); printf("bt(array, 1) = %d\n", bt(array, 1)); printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]); return 0; } |
Output:
btc(array, 35) = 0 array = [0]:x2, [1]:x108 btc(array, 35) = -1 array = [0]:x2, [1]:x100 bts(array, 35) = 0 array = [0]:x2, [1]:x108 btr(array, 35) = -1 array = [0]:x2, [1]:x100 bt(array, 1) = -1 array = [0]:x2, [1]:x100