_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.
Syntax
unsigned char _bittest(
long const *a,
long b
);
unsigned char _bittest64(
__int64 const *a,
__int64 b
);
Parameters
a
[in] A pointer to the memory to examine.
b
[in] The bit position to test.
Return value
The bit at the position specified.
Requirements
Intrinsic | Architecture | Header |
---|---|---|
_bittest |
x86, ARM, x64, ARM64 | <intrin.h> |
_bittest64 |
ARM64, x64 | <intrin.h> |
Remarks
This routine is only available as an intrinsic.
Example
// 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
See also
Phản hồi
https://aka.ms/ContentUserFeedback.
Sắp ra mắt: Trong năm 2024, chúng tôi sẽ dần gỡ bỏ Sự cố với GitHub dưới dạng cơ chế phản hồi cho nội dung và thay thế bằng hệ thống phản hồi mới. Để biết thêm thông tin, hãy xem:Gửi và xem ý kiến phản hồi dành cho