다음을 통해 공유


_bittestandcomplement, _bittestandcomplement64

Microsoft Specific

Generate an instruction which examines bit b of the address a, returns its current value, and sets the bit to its complement.

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

Parameters

  • [in, out] a
    A pointer to the memory to examine.

  • [in] b
    The bit position to test.

Return Value

The bit at the position specified.

Requirements

Intrinsic

Architecture

_bittestandcomplement

x86, ARM, x64 

_bittestandcomplement64

x64

Header file <intrin.h>

Remarks

This routine is only available as an intrinsic.

Example

// 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
}

Sample Output

Initial value: 1
Testing bit 1
Value changed to 3, Result: 0
Testing bit 0
Value changed to 0, Result: 1

See Also

Reference

Compiler Intrinsics