分享方式:


_bittestandcomplement, _bittestandcomplement64

Microsoft 特定的

產生的指令會檢查位址 b 的位元 a、傳回其目前值,並將位元設為它的補數。

語法

unsigned char _bittestandcomplement(
   long *a,
   long b
);
unsigned char _bittestandcomplement64(
   __int64 *a,
   __int64 b
);

參數

a
[in, out]要檢查之記憶體的指標。

b
[in]要測試的位位置。

傳回值

位於指定位置的位元。

需求

內建 架構
_bittestandcomplement x86、ARM、x64、ARM64
_bittestandcomplement64 x64、ARM64

標頭檔 < intrin.h>

備註

此常式僅可作為內建常式使用。

範例

// bittestandcomplement.cpp
// processor: x86, IPF, x64
#include <stdio.h>
#include <intrin.h>

#pragma intrinsic(_bittestandcomplement)
#ifdef _M_AMD64
#pragma intrinsic(_bittestandcomplement64)
#endif

int main()
{
   long i = 1;
   __int64 i64 = 0x1I64;
   unsigned char result;
   printf("Initial value: %d\n", i);
   printf("Testing bit 1\n");
   result = _bittestandcomplement(&i, 1);
   printf("Value changed to %d, Result: %d\n", i, result);
#ifdef _M_AMD64
   printf("Testing bit 0\n");
   result = _bittestandcomplement64(&i64, 0);
   printf("Value changed to %I64d, Result: %d\n", i64, result);
#endif
}
Initial value: 1
Testing bit 1
Value changed to 3, Result: 0
Testing bit 0
Value changed to 0, Result: 1

END Microsoft 特定的

另請參閱

編譯器內建函式