_bittest, _bittest64
Visual Studio 2015
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at _bittest, _bittest64.
Microsoft Specific**
Generates the bt instruction, which examines the bit in position b of address a, and returns the value of that bit.
unsigned char _bittest( long const *a, long b ); unsigned char _bittest64( __int64 const *a, __int64 b );
Parameters
[in] a
A pointer to the memory to examine.
[in] b
The bit position to test.
Return Value
The bit at the position specified.
| Intrinsic | Architecture | Header |
|---|---|---|
_bittest | x86, ARM, x64 | <intrin.h> |
_bittest64 | ARM, x64 | <intrin.h> |
This routine is only available as an intrinsic.
// bittest.cpp // processor: x86, ARM, x64 #include <stdio.h> #include <intrin.h> long num = 78002; int main() { unsigned char bits[32]; long nBit; printf_s("Number: %d\n", num); for (nBit = 0; nBit < 31; nBit++) { bits[nBit] = _bittest(&num, nBit); } printf_s("Binary representation:\n"); while (nBit--) { if (bits[nBit]) printf_s("1"); else printf_s("0"); } }
Number: 78002 Binary representation: 0000000000000010011000010110010
END Microsoft Specific
Show: